Spring注解之@Retention
作用是定义被它所注解的注解保留多久,一共有三种策略,定义在RetentionPolicy枚举中:
package java.lang.annotation;
/**
* Annotation retention policy. The constants of this enumerated type
* describe the various policies for retaining annotations. They are used
* in conjunction with the {@link Retention} meta-annotation type to specify
* how long annotations are to be retained.
*
* @author Joshua Bloch
* @since 1.5
*/
public enum RetentionPolicy {
/**
* Annotations are to be discarded by the compiler.
* 注解在编译时就被忽略
*/
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文件;但是不被VM运行时保留
*/
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
}
Spring注解之@Retention的更多相关文章
- spring注解源码分析--how does autowired works?
1. 背景 注解可以减少代码的开发量,spring提供了丰富的注解功能.我们可能会被问到,spring的注解到底是什么触发的呢?今天以spring最常使用的一个注解autowired来跟踪代码,进行d ...
- [转]Spring注解原理的详细剖析与实现
原文地址:http://freewxy.iteye.com/blog/1149128/ 本文主要分为三部分: 一.注解的基本概念和原理及其简单实用 二.Spring中如何使用注解 三.编码剖析spri ...
- spring注解式参数校验
很痛苦遇到大量的参数进行校验,在业务中还要抛出异常或者返回异常时的校验信息,在代码中相当冗长,今天我们就来学习spring注解式参数校验. 其实就是:hibernate的validator. 开始啦. ...
- Spring 注解(一)Spring 注解编程模型
Spring 注解(一)Spring 注解编程模型 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) Spring 注解系列 ...
- Spring 注解方式引入配置文件
配置文件,我以两种为例,一种是引入Spring的XML文件,另外一种是.properties的键值对文件: 一.引入Spring XML的注解是@ImportResource @Retention(R ...
- Spring注解原理
一.注解的基本概念和原理及其简单实用 注解(Annotation)提供了一种安全的类似注释的机制,为我们在代码中添加信息提供了一种形式化得方法,使我们可以在稍后某个时刻方便的使用这些数据(通过解析注解 ...
- spring注解扫描组件注册
最近对单点系统进行微服务拆分,被各个springboot的组件注册搞得云里雾里的.(有的是通过springboot的自动配置进IOC容器的,有的是自己添加构造方法添加进IOC容器.)决定抽时间将spr ...
- Spring注解原理的详细剖析与实现
本文主要分为三部分: 一. 注解的基本概念和原理及其简单实用 二. Spring中如何使用注解 三. 编码剖析spring@Resource的实现原理 一.注解的基本概念和原理及其简单实用 注解(An ...
- Spring 注解学习笔记
声明Bean的注解: @Component : 组件,没有明确的角色 @Service : 在业务逻辑层(service层)使用 @Repository : 在数据访问层(dao层)使用. @Cont ...
随机推荐
- redis中 Could not get a resource from the pool 异常解决
https://blog.csdn.net/qh_java/article/details/54669973
- HDU 4104 Discount(n个数不能构成的最小值)
http://acm.hdu.edu.cn/showproblem.php?pid=4104 题意:给出n个数,每个数最多只能用一次,每次可以选任意个数相加,求不能相加得到的最小值是多少. 思路: 先 ...
- BZOJ 2809: [Apio2012]dispatching(左偏树)
http://www.lydsy.com/JudgeOnline/problem.php?id=2809 题意: 思路:最简单的想法就是枚举管理者,在其子树中从薪水低的开始选起,但是每个节点都这样处理 ...
- 【Mysql】【Navicat For Mac】Navicat Premium for Mac v12.0.23 + macOS Sierra 10.12.6
参考地址:https://blog.csdn.net/womeng2009/article/details/79700667 [备注]我只用到了部分信息,就激活了 内容: Navicat Premiu ...
- 虚拟现实外包公司—北京动点飞扬软件承接VR/AR软件、游戏外包
欢迎通过以下方式联系北京动点飞扬软件外包业务咨询QQ:372900288 (全天在线) 咨询邮箱:SLteam@vip.qq.com 同时我们还承接 HTML5外包. kinect外包.Uni ...
- 使用fiddler轻轻松松制造客户端接口time out的情况
1.打开fiddler,过滤出你想要的请求 2.复制出你想要中断的请求 3.设置中断这个请求,bpu+请求,回车(详情请百度fiddle默认命令) 4.ctrl+x(清楚所有的请求),刷新页面,重新获 ...
- Java 通过get post 请求url
1️⃣.已获取小程序的access_token 为例,通过Get请求url import com.alibaba.fastjson.JSONObject; String wechatUrl = &qu ...
- jdbcTemplate 后台接口中的分页
Springboot+jdbcTemplate 对查询结果列表做分页, 之前开发的小项目,数据逐渐增多,每次返回所有的查询结果,耗费性能和时间 想到做分页. 于是从简单的分页做起. jdbcTemp ...
- sklearn.learning_curve
学习曲线函数: from sklearn.learning_curve import learning_curve 调用格式: learning_curve(estimator, X, y, trai ...
- isnull和sum的关系
这是我刚刚写存储过程的时候意识到的一个问题!!! 先问大家这样一个问题,print 100+null 等于多少? 在一组数据统计的过程中,只要使用到sum函数,就必须使用isnull函数包含起来,因 ...