元注解

元注解

  1. @Target:表示我们的注解可以用在哪些地方

//表示该注解只能使用在类和方法上
@Target(value = {ElementType.Method,ElementType.Type})
  1. @Retention 表示我们的注解在什么地方还有效

//runtime(运行时,编译时,源码时有效)>class(编译时,源码时有效)>source(只在源码时有效)
@Retention (value = RetentionPolicy.RUNTIME )
  1. @Documented 表示是否将我们的注解生成在JAVAdoc中

  2. @Inherited 子类可以继承父类的注解

原文地址:https://www.cnblogs.com/scenario/p/13748169.html