简体   繁体   English

Lombok 和 jackson - 冲突/不明确的属性名称定义

[英]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")这在我的情况下实际上是多余/不需要的,它可以工作

  • Note changing to private didn't fixed the issue注意更改为private并没有解决问题

Lombok change :龙目岛变化

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.

相关问题 使用Jackson 2.9.6的运动衫中的属性名称定义冲突 - Conflicting property name definitions in jersey ,using Jackson 2.9.6 如何在不访问源代码的情况下解决 jackson 中属性的冲突 getter 定义 - How to solve conflicting getter definitions for property in jackson without access to source org.codehaus.jackson.map.JsonMappingException:属性“ matchColumn”的设置器定义冲突:com.sun.rowset.JdbcRowSetImpl - org.codehaus.jackson.map.JsonMappingException: Conflicting setter definitions for property “matchColumn”: com.sun.rowset.JdbcRowSetImpl 属性“ thenComparing”的setter定义冲突: - Conflicting setter definitions for property “thenComparing”: "名称的持久性单元定义冲突" - Conflicting persistence unit definitions for name 如何避免具有相同属性名称和不同数据类型的属性的 getter 定义冲突 - How to avoid the Conflicting getter definitions for property with same attribute name with different datatype 无法读取 JSON:属性的设置器定义冲突 - Could not read JSON: Conflicting setter definitions for property Jackson ObjectMapper冲突的setter定义(Android.Graphics.Bitmap) - Jackson ObjectMapper Conflicting setter definitions (Android.Graphics.Bitmap) 导入冲突,导入名称“ Toast”不明确 - Conflicting import, imported name 'Toast' is ambiguous Jackson 动态属性名称 - Jackson dynamic property name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM