简体   繁体   English

如何使用XmlElement为dozer正确映射字段

[英]How to map fields correctly using XmlElement for dozer

I have the following field 我有以下字段

@Mapping("greatId")
@XmlElement(name = "great_key")
private String greatKey;

So my getters and setters are getGreatKey() , and setGreatKey(..) . 所以我的getter和setter是getGreatKey()setGreatKey(..) Then my JSON do not contain the response with field "great_key". 然后我的JSON不包含带有字段“great_key”的响应。 But if i add a getter getGreat_key() , then it returns the fields. 但是如果我添加一个getter getGreat_key() ,那么它将返回字段。 I dont want to add those getters. 我不想添加那些吸气剂。 What am i doing wrong ? 我究竟做错了什么 ?

I found exact same problem explained in : XmlElement ignored by Jackson during serialization 我发现完全相同的问题解释了: 在序列化期间Jackson忽略了XmlElement

Pretty sure that you are not using Jackson for serialization. 很确定你没有使用Jackson进行序列化。 ;) Get rid of the current serialization or make it respect the standard annotations. ;)摆脱当前的序列化或使其尊重标准注释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM