@JsonIgnore with @Getter Annotation
To put the @JsonIgnore to the generated getter method, you can use onMethod = @__( @JsonIgnore ). This will generate the getter with the specific annotation. For more details check http://projectlombok.org/features/GetterSetter.html
@Getter
@Setter
public class User {
private userName;
@Getter(onMethod = @__( @JsonIgnore ))
@Setter
private password;
}
Recently i had the same issue using jackson-annotation 2.9.0 and lombok 1.18.2
This is what worked for me:
@Getter
@Setter
public class User {
@JsonIgnore
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password;
So basically adding the annotation @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
means that the property may only be written for deserialization (using setter) but will not be read on serialization (using getter)