国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Spring容器初始化及問(wèn)題解決方案

瀏覽:8日期:2023-09-02 09:34:37

1.Spring bean組件 ”默認(rèn)為單例模式scope=“singleton, 運(yùn)行JavaApplication容器啟動(dòng)時(shí)自動(dòng)創(chuàng)建對(duì)象

scope=“prototype”為多例模式,請(qǐng)求條件下才創(chuàng)建對(duì)象

2beans組件 里面default-init-method初始化方法加載,范圍比較大,當(dāng)沒有此方法時(shí)不會(huì)報(bào)錯(cuò),default-destroy-method銷毀方法,default-lazy-init=“true/false” 對(duì)象延時(shí)實(shí)例化

3.bean組件里面init-method初始化無(wú)此方法,會(huì)報(bào)錯(cuò), destroy-method銷毀方法,lazy-init=“true/false” 延時(shí)實(shí)例化

注意:

1.銷毀方法對(duì)scope=“prototype”多例模式無(wú)效

2.AbstractApplicationContext可以關(guān)閉容器,可以調(diào)用close()方法,關(guān)閉容器,調(diào)用銷毀方法

3.對(duì)象延時(shí)實(shí)例化對(duì)多例模式?jīng)]有意義。

XML

<?xml version='1.0' encoding='UTF-8'?><beans xmlns='http://www.springframework.org/schema/beans' xmlns:context='http://www.springframework.org/schema/context' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:aop='http://www.springframework.org/schema/aop' xmlns:tx='http://www.springframework.org/schema/tx' xmlns:p='http://www.springframework.org/schema/p' xmlns:util='http://www.springframework.org/schema/util' xmlns:jdbc='http://www.springframework.org/schema/jdbc' xmlns:cache='http://www.springframework.org/schema/cache' xsi:schemaLocation=' http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd' default-init-method='initEmp' default-destroy-method='destroyEmp' default-lazy-init='true'> <bean init-method='initEmp' destroy-method='destroyEmp' lazy-init='false' scope='singleton' ></bean> </beans>

Test方法

//bean組件的默認(rèn)方式 @Test public void beanInitTest() { AbstractApplicationContext appContext=new ClassPathXmlApplicationContext('com/tracy/xml/bean-init-destroy.xml'); ApplicationContext app=new ClassPathXmlApplicationContext('com/tracy/xml/bean-init-destroy.xml'); Emp emp=app.getBean('emp',Emp.class); System.out.print(emp); appContext.close(); }

通過(guò)構(gòu)造完成初始bean屬性,可以通過(guò)初始化完成

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 国产日韩在线播放 | 看国产一级毛片 | 在线成人a毛片免费播放 | 久久国产欧美另类久久久 | 亚洲欧美综合久久 | 亚洲精品天堂一区 | 一级特黄国产高清毛片97看片 | 成年人免费在线视频 | 亚洲国产第一区二区三区 | 色内内免费视频播放 | 亚洲最黄视频 | 夜夜春夜夜夜夜猛噜噜噜噜噜 | a级片在线免费看 | jk制服福利在线播放 | 亚洲国产成人久久99精品 | 国产三级香港三韩国三级 | 91欧美精品综合在线观看 | 国产精品女在线观看 | 91香蕉成人 | 国产成人a一在线观看 | 18黄网站| 日韩高清在线二区 | 精品一区二区三区视频在线观看 | 国产在线视频自拍 | 国产亚洲精品九九久在线观看 | 精品国产一区二区三区成人 | 免费网站看v片在线香蕉 | 中文字幕在线观看一区二区 | 在线播放性xxx欧美 在线播放亚洲视频 | 亚洲男人的性天堂 | 久久精品亚洲精品一区 | 日韩在线视频中文字幕 | 交videos人妖 | 国产精品色内内在线播放 | 美女和男人免费网站视频 | 久久久久久久亚洲精品一区 | www.亚洲天堂 | 国产区香蕉精品系列在线观看不卡 | 无遮挡一级毛片私人影院 | 毛片在线播放网站 | 一级特黄特色的免费大片视频 |