lombok------关于@Builder will ignore the initializing expression entirely警告

时间:2024-03-22 12:30:08

推荐公众号

彩蛋哦!!!(或者公众号内点击网赚获取彩蛋)
lombok------关于@Builder will ignore the initializing expression entirely警告

问题描述

警告: @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, make the field final.
大致意思是@Builder将忽略类中的默认值,如果想要保留默认值那么添加@Builder.Default注解或者声明为final

解决

很多场景下声明final是不合适的,所以添加@Builder.Default是解决办法
未添加之前
lombok------关于@Builder will ignore the initializing expression entirely警告
添加之后
lombok------关于@Builder will ignore the initializing expression entirely警告