简体   繁体   中英

jackson:Issue with bean class having multiple setters with same name and different type paramas

json simply giving mapperException Conflicting setter definitions for property

public void setJanuary(String january) {
    try {
        setJanuary(Float.parseFloat(january));
    } catch (NumberFormatException exception) {
        setJanuary(0);
    }
}public void setJanuary(float january) {
    this.january = january;
}

通过使用注释@JsonSetter解决了问题我们从Json使用的setter

@JsonIgnore排除的setter方法使用@JsonIgnore注释。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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