用spring的InitializingBean的afterPropertiesSet来初始化
来源:互联网 发布:软件实施管理制度 编辑:程序博客网 时间:2024/05/24 01:57
org.springframework.beans.factory包下有一个接口是InitializingBean 只有一个方法:
/**
* Invoked by a BeanFactory after it has set all bean properties supplied
* (and satisfied BeanFactoryAware and ApplicationContextAware).
* <p>This method allows the bean instance to perform initialization only
* possible when all bean properties have been set and to throw an
* exception in the event of misconfiguration.
* @throws Exception in the event of misconfiguration (such
* as failure to set an essential property) or if initialization fails.
*/
void afterPropertiesSet() throws Exception;
这个方法将在所有的属性被初始化后调用。
但是会在init前调用。
但是主要的是如果是延迟加载的话,则马上执行。
所以可以在类上加上注解:
import org.springframework.context.annotation.Lazy;
@Lazy(false)
这样spring容器初始化的时候afterPropertiesSet就会被调用。
只需要实现InitializingBean接口就行。
如果代码在这里初始化的话,半天都找不到。。
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet初始化
- Spring InitializingBean的afterPropertiesSet方法
- Spring InitializingBean的afterPropertiesSet方法
- Spring InitializingBean的afterPropertiesSet与init-method、@PostConstruct
- 用spring的InitializingBean作初始化
- spring的InitializingBean的 afterPropertiesSet 方法 和 init-method配置的 区别联系
- spring的InitializingBean的 afterPropertiesSet 方法 和 init-method配置的 区别联系
- spring的InitializingBean的 afterPropertiesSet 方法 和 init-method配置的 区别联系
- 从源码实现的角度解析spring的InitializingBean的afterPropertiesSet方法和init-method区别和应用
- spring初始化Bean的方法---实现 InitializingBean接口
- BeanFactoryAware在InitializingBean之后执行,奇怪的Spring初始化顺序?
- spring的InitializingBean介绍
- spring的InitializingBean介绍 .
- 数据库--MySQL体系结构
- 泛型
- 实现一个栈(元素遵守先入后出顺序),能够通过 min 方法在 O(1)时间内获取栈中的最小元素。同时,栈的基本操作:入栈(Push)、出栈(Pop),也是在O(1)时间内完成的
- Hello World!
- 要考驾照科目二了,好紧张
- 用spring的InitializingBean的afterPropertiesSet来初始化
- Android 5.0 Activity切换动画
- Java程序猿之网络编程(29)
- Mybatis开发dao的方法--原始dao篇
- 通过AJAX与Servlet进行交互:通过JSON传递数据
- Linux上Oracle 11g安装步骤图解
- BZOJ 3555 [Ctsc2014] 企鹅QQ [求纠错……]
- 机器人制作入门(三)----速度控制
- OpenCV+Tesseract进行OCR学习(二)文字识别