Lombok的一些坑
所属分类 java
浏览量 894
第一个字母小写,第二个字母大写的属性
get set方法 命名 与 Java标准的行为不一样
java 标准
public class Bean {
private String xYz;
private String abc;
public String getxYz() {
return xYz;
}
public String getAbc() {
return abc;
}
注意 xYz 保持原样
lombook 生成时 直接 首字母大写
解决方案
属性的前两个字母必须小写
@Accessor(chain = true)
支持链式调用
cglib使用 jdk Introspector类的方法
只获取返回值是void类型的setxxxx方法 ,返回值非 void 的 set 方法会被忽略
# Introspector.java 第520行
if (int.class.equals(argTypes[0]) && name.startsWith(GET_PREFIX)) {
pd = new IndexedPropertyDescriptor(this.beanClass, name.substring(3), null, null, method, null);
// 只获取返回值是void类型的setxxxx方法
} else if (void.class.equals(resultType) && name.startsWith(SET_PREFIX)) {
// Simple setter
pd = new PropertyDescriptor(this.beanClass, name.substring(3), null, method);
if (throwsException(method, PropertyVetoException.class)) {
pd.setConstrained(true);
}
}
上一篇
下一篇
go程序设计语言01_03入门之查找重复的行
HikariCP为什么这么快
Spring事务失效的原因
GO获取变量类型
go基本语法例子
mac安装xcode命令行工具