Spring下的Bean初始化和销毁两种方式

1、通过在配置文件中的Bean元素下的init-method属性定义一个在此个Bean中的进行初始化的方法,通过设定其destory-method属性,指定方法销毁Bean

2、通过继承org.springframework.beans.factory.InitializingBean接口,实现其afterPropertiesSet()方法对Bean进行初始化,通过继承org.springframework.beans.factory.DisposableBean接口,实现其destroy()方法来进行Bean的销毁

你可能感兴趣的:(spring,bean)