java通过反射获取bean字段注解@Column中的信息
直接上代码吧:
Field field; Field[] fields=clas.getDeclaredFields(); for (int i = 0; i <fields.length ; i++) { fields[i].setAccessible(true); } for (int i = 0; i <fields.length ; i++) { field=clas.getDeclaredField(fields[i].getName()); Column column=field.getAnnotation(Column.class); if(column!=null){
System.out.println(column.name());
System.out.println(column.length());
}
}