首页 > 编程语言 > 详细

spring 的 InitializingBean

时间:2018-09-14 11:30:40      阅读:136      评论:0      收藏:0      [点我收藏+]

public interface 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;

}

如果想在bean初始化的时候做一些操作,则可以继承自InitializingBean 接口;

 

这个接口只有一个方法就是afterPropertiesSet 作用就是当bean的各个属性初始化之后,会调用此方法

 

spring的具体实现是在AbstractAutowireCapableBeanFactory类中 invokeInitMethods方法会调用 afterPropertiesSet 

 

spring 的 InitializingBean

原文:https://www.cnblogs.com/liguangming/p/9645396.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!