I am experimenting in combining Jackson and Lombok. Those are my classes:
package testelombok;
import com.fasterxml
From Jan Rieke's Answer
Since lombok 1.18.4, you can configure what annotations are copied to the constructor parameters. Insert this into your
lombok.config:lombok.copyableAnnotations += com.fasterxml.jackson.annotation.JsonPropertyThen just add
@JsonPropertyto your fields:...
You'll need a @JsonProperty on every field even if the name matches, but that is a good practice to follow anyway. You can also set your fields to public final using this, which I prefer over getters.
@ToString
@EqualsAndHashCode
@Wither
@AllArgsConstructor(onConstructor=@__(@JsonCreator))
public class TestFoo {
@JsonProperty("xoom")
public final String x;
@JsonProperty("z")
public final int z;
}
It should also work with getters (+setters) though.