I'm running into an issue with my pojo created using lombok with jsonproperty annotation. It doesn't respect the json annotation. And, when i create an object using the lombok builder it uses the field names on the object instead of json property.
Could someone help see what am I missing here. I just started using lombok so im hoping something straightforward. I'm running the code on Intellij
@Data
@Builder
public class pojo {
@JsonProperty("grant_type")
private final String grantType = "xyz";
@JsonProperty("client_id")
private String clientId;
}
It's default behavior of @Builder
.
If we want the builder with setClientId
, We can add setterPrefix = "set"
into @Builder
.
@Data
@Builder(setterPrefix = "set")
public class pojo {
@JsonProperty("grant_type")
private final String grantType = "xyz";
@JsonProperty("client_id")
private String clientId;
}
@Data
would generate a pair of setter/getter. But setter is a member method of pojo, not pojoBuilder
's.
More details of Builder is here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.