使用实现了ConfigurableListableBeanFactory接口的XmlBeanFactory ,可以使用destroySingletons方法通知销毁所有的singleton实例,这时候,如果我们为bean定义了destroy-methd属性,就会进行调用,我们可以在其中进行一些收尾的工作
SimpleBean.java











































配置文件:




















测试代码:








































运行结果:
this is info from afterpropertiesSet from SimpleBean
before destroy
this is info from destroy method
after destory