1.正常情况下
private Integer maxKeys = 20;
2.bulilder模式下
@Builder.Default private Integer maxKeys = 20;
注意:@Builder.Default会使无参构造创建出的对象默认值失效。springboot中controller层自动装配前端表单数据构造对象使用的就是无参构造方法,所以Builder模式下要注意判断值的有效性。
参考链接:https://reinhard.codes/2016/07/13/using-lomboks-builder-annotation-with-default-values/