【发布时间】:2014-05-27 09:10:30
【问题描述】:
我无法获得 bean 的注释,我正在使用 spring 框架:
可运行的测试类:
public class Main {
public static void main(String[] args) {
PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(Test.class,"foo");
Method m=pd.getReadMethod();
System.out.println(m.isAnnotationPresent(Annot.class));
}
}
豆类;
public class Test {
private String foo;
@Annot
public String getFoo() {
return foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
注解类:
public @interface Annot {
}
主类得到“false”作为输出...为什么?
【问题讨论】:
标签: java spring annotations