开发者

Unable to find class annotation

开发者 https://www.devze.com 2022-12-13 14:52 出处:网络
Why does this code print 0? @Table(name = \"source\") public class SourceDetails implements DatabaseEntity{

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

精彩评论

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