I want to know a class\'s some member variable\'s annotations , I use BeanInfo beanInfo = Introspector.getBeanInfo(User.class) to introspect a class , and use <
Or you could try this
try {
BeanInfo bi = Introspector.getBeanInfo(User.getClass());
PropertyDescriptor[] properties = bi.getPropertyDescriptors();
for(PropertyDescriptor property : properties) {
//One way
for(Annotation annotation : property.getAnnotations()){
if(annotation instanceof Column) {
String string = annotation.name();
}
}
//Other way
Annotation annotation = property.getAnnotation(Column.class);
String string = annotation.name();
}
}catch (IntrospectonException ie) {
ie.printStackTrace();
}
Hope this will help.