用spring的InitializingBean的afterPropertiesSet来初始化
来源:互联网 发布:mysql配置文件怎么写 编辑:程序博客网 时间:2024/05/24 00:59
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级联查询的优化
- VC6.0设定UNICODE编译环境
- 深入Java,初探JVM
- 电话本联系人匹配长度修改
- 用spring的InitializingBean的afterPropertiesSet来初始化
- Spring JPA Integration
- 了解 JavaScript 应用程序中的内存泄漏
- Codeforces Round #149 (Div. 2)——B
- in与exist , not in与not exist 的区别
- 软件测试过程中的BUG管理
- <<Effecitve C++>>笔记2
- IBM Messaging and Collaboration Roadmap
- PHP DES加密解密(这个类有问题,提醒一下大家,解密后字符面有一段乱码,但看不到)