Can't make Jackson and Lombok work together

后端 未结 14 1406
伪装坚强ぢ
伪装坚强ぢ 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:11

    I had exactly the same issue, "solved" it by adding the suppressConstructorProperties = true parameter (using your example):

    @Value
    @Wither
    @AllArgsConstructor(suppressConstructorProperties = true)
    public class TestFoo {
        @JsonProperty("xoom")
        private String x;
        private int z;
    }
    

    Jackson apparently does not like the java.beans.ConstructorProperties annotation added to constructors. The suppressConstructorProperties = true parameter tells Lombok not to add it (it does by default).

提交回复
热议问题