用spring的InitializingBean的afterPropertiesSet来初始化
来源:互联网 发布:淘宝客 很多退款 编辑:程序博客网 时间:2024/06/07 08:45
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接口就行。
如果代码在这里初始化的话,半天都找不到。。
转载出处:http://www.cnblogs.com/java-boy/archive/2012/12/21/2827729.html
- 用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介绍 .
- C++第七次做作业
- cocos2D-X源码分析之从cocos2D-X学习OpenGL(7)----GLSL
- nginx不支持pathinfo的原因以及解决办法
- 从0开始学习 GitHub 系列之「向GitHub 提交代码」
- 限制允许某些IP访问服务器
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 欢迎使用CSDN-markdown编辑器
- AndroidStudio中使用ButterKnife注解
- iOS 9后台定位崩溃问题
- 微信-------通过开发者请求验证
- 栈与堆的区别
- Linux下vim打不开
- 【例题】【动规(树形)】NKOJ 1217 选课、NKOJ 2317 选课2.0
- iOS开发设备申请方案