spring InitializingBean和DisposableBean init-method 和destroy-method @PostConstruct @PreDestroy
阿新 • • 發佈:2018-11-21
對於初始化函式:
@PostConstruct 註解的方法
InitializingBean介面定義的回撥afterPropertiesSet()
Bean配置中自定義的初始化函式
對於析構則與上相同:
@PreDestroy註解的方法
DisposableBean介面定義的回撥destroy()
Bean配置中自定義解構函式
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" default-init-method="init" default-destroy-method="close" > <bean id="user0" class="com.test.service.UserServiceIml" init-method="testInit" destroy-method="testBeforeDesstroy">
https://blog.csdn.net/windsunmoon/article/details/44276765