自定义注解,andjdk提供的元注解

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface FruitName {
    String value() default "";
}

/**
*
元注解:
  @Target:
    取值:ElementType.method  作用于方法
      ...field         ..属性
      ...type         ..类,接口,枚举
      ...package       ..包
     ...constructor     ..构造器
      ...local_variable   ..局部变量
  @Retention
    取值:RetentionPolicy.runtime  一般取runtime 运行时有效
        ....class          .class文件中有效
        ....source          源文件中有效
  @Documented  用于生成java doc
  @Inherited   这个注释不仅能作用于此类,还能作用于此类的所有子类
   
*/

  

参考自 :

http://www.cnblogs.com/peida/archive/2013/04/24/3036689.html

http://www.cnblogs.com/peida/archive/2013/04/26/3038503.html

原文地址:https://www.cnblogs.com/liyong888/p/7792187.html