【发布时间】:2021-09-20 05:03:06
【问题描述】:
我有一个由 jsonSchemaPojo2 创建的 java pojo:
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonPropertyOrder({
"CardBranding"
})
public class RewardsProcessing implements Serializable
{
@JsonProperty("CardBranding")
@NotNull
private String cardBranding
public RewardsProcessing(String cardBranding){
this.cardBranding = cardBranding
}
@JsonProperty("CardBranding")
public String getCardBranding(){return cardBranding; }
@JsonProperty("CardBranding")
public void setCardBranding(String cardBranding){ this.cardBranding = cardBranding}
}
奖励收集:
[
{CardBranding : "1"},
{CardBranding : "2"}
]
以下代码将mongo响应解析成java pojo
AggregationResults results = mongoTemplate.aggregate(agg, "Rewards", RewardsProcessing.class);
问题是我在生成的 java 对象中得到了 null。聚合区分大小写。
我有两个选择:
-
使用 jsonschemapojo2 中的某些属性将 cardBranding 字段设为大写。我尝试研究但没有找到。 Schemapojo2 默认将字段设置为小写。
-
配置聚合方法忽略大小写。
提前致谢!!
【问题讨论】:
标签: java mongodb spring-boot mongotemplate jsonschema2pojo