Can't make Jackson and Lombok work together

后端 未结 14 1350
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 13:48

I am experimenting in combining Jackson and Lombok. Those are my classes:

package testelombok;

import com.fasterxml         


        
14条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 14:23

    I had a different issue and it was with the boolean primitive types.

    private boolean isAggregate;
    

    It was throwing the following error as a result

    Exception: Unrecognized field "isAggregate" (class 
    

    Lambok converts isAggregate to isAggregate() as a getter making the property internally to lombok as aggregate instead isAggregate. The Jackson library doesn't like it and it needs isAggregate property instead.

    I updated the primitive boolean to Wrapper Boolean to work around this issue. There are other options for you if you are dealing with boolean types, see the reference below.

    Sol:

    private Boolean isAggregate;
    

    ref: https://www.baeldung.com/lombok-getter-boolean

提交回复
热议问题