[英]How to Ignore a JsonProperty to be stored in DynamoDB
这是我使用 DynamodbMapper 存储在 DynamoDB 中的 POJO
@DynamoDBTable(tableName = "Data")
// @JsonIgnoreProperties(value = { "content" })
public class Data {
@DynamoDBRangeKey(attributeName = "Url")
@DynamoDBAutoGeneratedKey
@JsonProperty("url")
private String url;
@DynamoDBHashKey(attributeName = "UserName")
@JsonProperty("userName")
private String userName;
@JsonProperty("title")
@DynamoDBAttribute(attributeName = "Title")
private String pasteTitle;
@JsonProperty("content")
private String content;
@JsonProperty("date")
@DynamoDBAttribute(attributeName = "Date")
private String date;
}
每次我运行DynamoDBMapper.save(data)
时,它也会存储content
,即使它没有DynamoDBAttribute
注释。 通过使用@JsonIgnoreProperties(value = { "content" })
它使值成为 null 并且不存储内容。 但我想将内容存储在 S3 而不是 DynamoDB 中,因此寻找一种在 DynamoDBAttribute 中忽略它的方法。
您可以使用@DynamoDBIgnore
- AWS 文档
在您的示例中:
@DynamoDbIgnore
public String getContent() {
return content;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.