簡體   English   中英

如何忽略要存儲在 DynamoDB 中的 JsonProperty

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM