java的四个元注解 @Retention @Target @Document @Inherited
2024-10-19 11:40:15
1. @Retention :注解的保留位置
@Retention(RetentionPolicy.SOURCE) //注解仅存在于源码中,在class字节码文件中不包含
@Retention(RetentionPolicy.CLASS) //默认的保留策略,注解会在class字节码文件中存在,但运行时无法获得
@Retention(RetentionPolicy.RUNTIOME) //注解会在class字节码文件中存在,在运行时可以通过反射获取到
2. @Target : 注解的作用目标
@Target(ElementType.TYPE) //接口、类、枚举、注解
@Target(ElementType.FIELD) //字段、枚举的常量
@Target(ElementType.METHOD) //方法
@Target(ElementType.PARAMETER) //方法参数
@Target(ElementType.CONSTRUCTOR) //构造函数
@Target(ELementType.LOCAL_VARIABLE) //局部变量
@Target(ElementType.ANNOTATION_TYPE) //注解
@Target(ElementType.PACKAGE) //包
3. @Document : 说明注解将被包含在javadoc中
4. @Inherited : 说明子类可以继承父类中的注解
@Target简单图
最新文章
- 模块化之Spring3.0 web fragment和gradle构建项目
- sae flask 微信公众平台开发
- WPF Datagrid multiple selecteditems in MVVM
- SQL Server 内存中OLTP内部机制概述(一)
- Visual Studio发布Web项目报错:Unable to add 'xxx' to the Web site. Unable to add file 'xxx'. The specified file could not be encrypted.
- miracast 协议wifi display
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) B. Guess the Permutation 水题
- jquery的smartWizard插件使用方法
- python2与python3
- list遍历
- Material Design学习-----CollapsingToolbarLayout
- 注册登录系统项目思路 -- javaweb
- bootstrap轮播和百叶窗
- 【lamba】java 8的新特性
- oracle 主键,非空,检查,唯一,默认,外键约束
- 5款Python程序员高频使用开发工具推荐
- python机器学习-sklearn挖掘乳腺癌细胞(三)
- VisualStuido C# Files 的值“<;<;<;<;<;<;<; .mine”无效。路径中具有非法字符。
- expr的字符串操作 表达式: length, index, match, substr等
- Net操作Excel_NPOI