基础注解
Override WebServlet
元注解
@Target 注解的作用目标
@Retention 注解的生命周期
@Documented 注解是否应当被包含在javadoc中
@Inherited 是否允许子类继承该注解
- @Target 注解的使用范围
packages types (类 接口 枚举)
类型成员(方法 构造方法 成员变量 枚举值)
方法参数和本地变量
/** Class, interface (including annotation type), or enum declaration */
TYPE,
/** Field declaration (includes enum constants) */
FIELD,
/** Method declaration */
METHOD,
/** Formal parameter declaration */
PARAMETER,
/** Constructor declaration */
CONSTRUCTOR,
/** Local variable declaration */
LOCAL_VARIABLE,
/** Annotation type declaration */
ANNOTATION_TYPE,
/** Package declaration */
PACKAGE,
/**
* Type parameter declaration
*
* @since 1.8
*/
TYPE_PARAMETER,
/**
* Use of a type
*
* @since 1.8
*/
TYPE_USE
- Retention
/**
* Annotations are to be discarded by the compiler.
只能在源文件.java 文件中保留。.class 文件中不能保留
*/
SOURCE,
/**
* Annotations are to be recorded in the class file by the compiler
* but need not be retained by the VM at run time. This is the default
* behavior.
*/
CLASS,
/**
* Annotations are to be recorded in the class file by the compiler and
* retained by the VM at run time, so they may be read reflectively.
*
* @see java.lang.reflect.AnnotatedElement
*/
RUNTIME
网友评论