青菜

注册

 

发新话题 回复该主题

Bean销毁的方式与顺序 [复制链接]

1#
北京中科医院忽悠         https://m-mip.39.net/baidianfeng/mipso_5154118.html

与Bean的初始化相对的是销毁,方式有:

PreDestroy注解作用于方法

实现DisposableBean接口,复写destroy方法

自定义destroyMethod:xmlbeandestroy-method="beanDestroy"属性、

Bean(destroyMethod="beanDestroy")、BeanDefinitionBuilder#setDestroyMethodName

示例代码:

springxml配置文件

beanid="user1"class="constxiong.User"destroy-method="beanDestroy"propertyname="source"value="xml"//bean!--开启注解能力--context:

分享 转发
TOP
发新话题 回复该主题