spring::ioc::生命周期

生命周期

init()

在实例化 bean 时,立即调用该方法

<?xml version="1.0" encoding="UTF-8"?>
<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-3.0.xsd">

   <bean id="helloWorld" 
       class="com.tutorialspoint.HelloWorld"
        <!--在实例化开始调用init()方法,在销毁时调用destroy方法-->
       init-method="init" destroy-method="destroy">
       <property name="message" value="Hello World!"/>
   </bean>
</beans>

destroy()

posted @ 2022-11-27 00:15  壹剑霜寒十四州  阅读(18)  评论(0编辑  收藏  举报