问题描述
我收到警告消息:
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]
我有最新的lombok 1.18.10和fastxml.jackson-version 2.7.5
I have latest lombok 1.18.10 and fasterxml.jackson-version 2.7.5
我发现了类似的问题,但应该已在2.7中修复. 4(关闭)
I found similar issue but it should have been fixed in 2.7.4 (closed)
我认为这毕竟可以更改为2.7.4,可以解决此问题.
I think this can be changed for 2.7.4 after all, can fix this.
代码:
@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?
似乎新的龙目岛版本也将@JsonProperty("Balance")
添加到了生成的二传手中,并造成了这种困惑
It seems that new Lombok version added @JsonProperty("Balance")
to generated setter also and create this confusion
编辑
在我删除@JsonProperty("Balance")
时的问题已解决,该情况实际上对我而言是不需要的
Issue fixed when I removed @JsonProperty("Balance")
which is actually unneeded in my case
推荐答案
我们升级了Lombok版本,现在它还将@JsonProperty("Balance")
添加到了生成的setter中
We upgrade Lombok version and it now added @JsonProperty("Balance")
also to generated setter
此重复的@JsonProperty
在日志中创建了WARN,并且创建响应失败(无异常)
This duplicate @JsonProperty
created a WARN in log and also failed creating response (without exception)
我删除了@JsonProperty("Balance")
,它在我的情况下实际上是多余的/不需要的,并且有效
I removed @JsonProperty("Balance")
which is actually redundant/unneeded in my case and it works
- 将笔记更改为
private
不能解决问题
- Note changing to
private
didn't fixed the issue
这篇关于龙目岛和杰克逊-冲突/模棱两可的属性名称定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!