Spring InitializingBean的afterPropertiesSet方法
来源:互联网 发布:java开发者 编辑:程序博客网 时间:2024/05/21 04:39
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初始化
- InitializingBean afterPropertiesSet方法
- spring的InitializingBean的 afterPropertiesSet 方法 和 init-method配置的 区别联系
- spring的InitializingBean的 afterPropertiesSet 方法 和 init-method配置的 区别联系
- spring的InitializingBean的 afterPropertiesSet 方法 和 init-method配置的 区别联系
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- 用spring的InitializingBean的afterPropertiesSet来初始化
- Spring InitializingBean的afterPropertiesSet与init-method、@PostConstruct
- 从源码实现的角度解析spring的InitializingBean的afterPropertiesSet方法和init-method区别和应用
- Spring afterPropertiesSet方法
- Spring afterPropertiesSet方法
- spring源码解读-InitializingBean的实现方法
- spring的InitializingBean介绍
- android 颜色值
- 读取FAT16文件
- XCode 6 新建项目 无法全屏
- Instrument 之 time Profiler
- python IPy库
- Spring InitializingBean的afterPropertiesSet方法
- Mifare Classic Tool (MCT),Android平台RFID工具
- LUA string库详解
- js获取元素
- Maven Setting.xml 配置说明
- Linux常用命令大全100条
- 返回上一级出现nested pop animation can result in corrupted navigation bar
- 堆排序
- 关于Debug和Release之本质区别的讨论(主要针对VC6.0和VS2003.net编译工具而言)