[英]Lombok and jackson - Conflicting/ambiguous property name definitions
I get a WARN message:我收到一条警告消息:
com.fasterxml.jackson.databind.JsonMappingException: Conflicting/ambiguous property name definitions (implicit name 'balance'): found multiple explicit names: [{}Balance, Balance], but also implicit accessor: [method ResponseVO#getBalance(0 params)][visible=true,ignore=false,explicitName=false]
I have latest lombok 1.18.10 and fasterxml.jackson-version 2.7.5我有最新的 lombok 1.18.10 和 fasterxml.jackson-version 2.7.5
I found similar issue but it should have been fixed in 2.7.4 (closed)我发现了类似的问题,但它应该已在 2.7.4 中修复(已关闭)
Jackson 2.7.1 and Lombok: 'Conflicting/ambiguous property name definitions' #1122
Jackson 2.7.1 和 Lombok:“冲突/不明确的属性名称定义”#1122
I think this can be changed for 2.7.4 after all, can fix this.
我认为这毕竟可以为 2.7.4 更改,可以解决这个问题。
Code:代码:
@Data
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor
public class ResponseVO implements Serializable {
private static final long serialVersionUID = 1;
@JacksonXmlProperty(localName = "Balance")
@JsonProperty("Balance")
@JacksonXmlElementWrapper(useWrapping = false)
List<BalanceResponseVO> balance;
Is it relevant warning?这是相关的警告吗? how can I fix/remove this warning?
如何修复/删除此警告?
It seems that new Lombok version added @JsonProperty("Balance")
to generated setter also and create this confusion似乎新的 Lombok 版本也将
@JsonProperty("Balance")
添加到生成的 setter 并造成这种混乱
EDIT编辑
Issue fixed when I removed @JsonProperty("Balance")
which is actually unneeded in my case当我删除
@JsonProperty("Balance")
时问题已修复,这在我的情况下实际上是不需要的
We upgrade Lombok version and it now added @JsonProperty("Balance")
also to generated setter我们升级了 Lombok 版本,现在它也添加了
@JsonProperty("Balance")
到生成的 setter
This duplicate @JsonProperty
created a WARN in log and also failed creating response (without exception)这个重复的
@JsonProperty
在日志中创建了一个 WARN 并且也未能创建响应(无异常)
I removed @JsonProperty("Balance")
which is actually redundant/unneeded in my case and it works我删除
@JsonProperty("Balance")
这在我的情况下实际上是多余/不需要的,它可以工作
private
didn't fixed the issueprivate
并没有解决问题FEATURE: Lombok now knows exactly how to treat @com.fasterxml.jackson.annotation.JsonProperty and will copy it to the right places for example when making builders.
功能:Lombok 现在确切知道如何处理 @com.fasterxml.jackson.annotation.JsonProperty 并将其复制到正确的位置,例如在制作构建器时。 Issue #1961 Issue #1981
问题 #1961 问题 #1981
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.