问题
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
I found similar issue but it should have been fixed in 2.7.4 (closed)
Jackson 2.7.1 and Lombok: 'Conflicting/ambiguous property name definitions' #1122
I think this can be changed for 2.7.4 after all, can fix this.
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
EDIT
Issue fixed when I removed @JsonProperty("Balance") which is actually unneeded in my case
回答1:
We upgrade Lombok version and it now added @JsonProperty("Balance") also to generated setter
This duplicate @JsonProperty created a WARN in log and also failed creating response (without exception)
I removed @JsonProperty("Balance") which is actually redundant/unneeded in my case and it works
- Note changing to
privatedidn't fixed the issue
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. Issue #1961 Issue #1981
来源:https://stackoverflow.com/questions/58689035/lombok-and-jackson-conflicting-ambiguous-property-name-definitions