Want to Add @JsonIgnore property on Password in response Json Want to Add @JsonIgnore property on Password in response Json spring spring

Want to Add @JsonIgnore property on Password in response Json


Try using both @JsonIgnore and @JsonProperty in your class like this:

private String password;@JsonIgnorepublic String getPassword() {    return password;}@JsonPropertypublic void setPassword(String password) {    this.password = password;}


You can do it this way too if you don't want to manually create the getters/setters (eg. when using lombok's @Data)

@JsonProperty(access = Access.WRITE_ONLY)private String password;


I think you should use DTO Pattern to set / change password.