Java Lombok@Data annotation将字段名称从isood更改为good
我有一个DTO,它使用Java Lombok@Data annotation将字段名称从isood更改为good,java,annotations,getter,lombok,setter,Java,Annotations,Getter,Lombok,Setter,我有一个DTO,它使用@Data注释lombok,以生成getter和setters: @Data public class SomeDto { protected boolean isGood; } 奇怪的是,现在我的getter已经从getisGood()重命名为isGood(),setter的名称是setGood(),而不是setIsGood()。 例如: 另外,当我在JSON中使用此DTO的端点上发出请求时,返回: {"good": false} 鉴于本应为
@Data
注释lombok
,以生成getter
和setters
:
@Data
public class SomeDto {
protected boolean isGood;
}
奇怪的是,现在我的getter已经从getisGood()
重命名为isGood()
,setter的名称是setGood()
,而不是setIsGood()
。
例如:
另外,当我在JSON中使用此DTO的端点上发出请求时,返回:
{"good": false}
鉴于本应为:
{"isGood": false}
有人知道问题出在哪里吗?我怀疑
isGood
开头的“是”可能会给龙目山带来混乱。非常感谢您提供的任何帮助。我想惯例是,对于布尔值,getter称为isGood,setter称为setGood。所以你的布尔值应该被称为“好”
也在文档中:)
您可以将布尔值更改为布尔值,请查看。
{"isGood": false}
lombok.getter.noIsPrefix = [true | false] (default: false)
If set to true, getters generated for boolean fields will use the get prefix instead of the defaultis prefix, and any generated code that calls getters, such as @ToString, will also use get instead of is