与上一篇中的定制初始化行为相似,Spring也提供了两种方法定制Bean销毁之前的特定行为。如下:
1.使用destroy-method属性。
2.实现DisposableBean接口。该接口中提供了一个方法:void destroy()throws Exception;