用spring的InitializingBean的afterPropertiesSet来初始化
来源:互联网 发布:徐州市网络电子备课 编辑:程序博客网 时间:2024/05/27 20:38
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介绍 .
- 线程管理(一)AsyncTask与Thread的差别
- 下载Tomcat源码,并作为工程导入到Eclipse中
- 怎样选择(FC-SAN)光纤通道(存储)交换机
- 使用tcmalloc,它的central freelist很多,一直没有释放
- dxmemdata 连接 dbgrideh进行排序
- 用spring的InitializingBean的afterPropertiesSet来初始化
- tomcat7 源码学习(源码导入eclipse)
- 【精品推荐】像极百度传课iOS版,非常赞的教育类应用
- iOS个人整理08-touch触摸事件和手势识别器
- Yii2 数据操作Query Builder
- 【精品推荐】程序员必定会爱上的十款软件:不用就太浪费了@^@
- noi1789:算24——搜索
- Hibernate注解详细解析
- 定时任务