##问题
@Data@Builderpublic class Demo { @Tolerate public Demo(){ } private int type = 2; private String url;}
通过builder模式,如果不设置type,还指望它能够设置2,恐怕要令你失望了。
##告警
Warning:(95, 30) java: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. if it is not supposed to be settable during building, add @Builder.Constant.
升级到最新版
org.projectlombok lombok 1.16.16 provided
@Builder.Defaultprivate int type = 2;
这样就ok了。
##doc
- [Using Lombok’s annotation with default values]()
想获取最新内容,请关注微信公众号