开发者

Unable to find class annotation

Why does this code print 0?

@Table(name = "source")
public class SourceDetails implements DatabaseEntity{

    public static void main(String[] ar开发者_如何学编程gs) {
        System.out.println(SourceDetails.class.getAnnotations().length);
    }
...
}


Because you didn't set the retention of the annotation to runtime.

@Retention(RetentionPolicy.RUNTIME)
@interface Table{
  String name();

  int intValue();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜