久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

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

Spring容器初始化及問題解決方案

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

1.Spring bean組件 ”默認為單例模式scope=“singleton, 運行JavaApplication容器啟動時自動創(chuàng)建對象

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

2beans組件 里面default-init-method初始化方法加載,范圍比較大,當沒有此方法時不會報錯,default-destroy-method銷毀方法,default-lazy-init=“true/false” 對象延時實例化

3.bean組件里面init-method初始化無此方法,會報錯, destroy-method銷毀方法,lazy-init=“true/false” 延時實例化

注意:

1.銷毀方法對scope=“prototype”多例模式無效

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

3.對象延時實例化對多例模式?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組件的默認方式 @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(); }

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

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 久久人体视频 | 午夜免费视频 | 精品视频一区二区三区在线观看 | 999这里只有是极品 免费的一级黄色片 | 国产一级片 | 91精品国产99久久久久久红楼 | 亚洲午夜电影 | 91久久精品国产91久久性色tv | 综合激情av | 在线久草 | 久久精品2| gav成人免费播放视频 | 狠狠躁夜夜躁人人爽天天高潮 | 久久成人精品 | 精品国产91亚洲一区二区三区www | 欧美精品福利 | 瑟瑟视频在线看 | 国产在线观看一区 | 成人a网 | 久草高清在线 | 国产高清美女一级a毛片久久 | 91精品午夜 | 亚洲精品久久久久999中文字幕 | 色女人的天堂 | 国产91 在线播放 | www.久久久 | 九九热视频在线 | 精品国产一区二区三区av片 | 国产依人| 日本美女影院 | 欧美日韩一区二区三区免费视频 | 欧美精品被 | 中文字幕乱码亚洲精品一区 | 日韩成人片 | 91网站在线看 | 国产在线一区二区三区 | 免费视频成人 | 碰碰视频| 91看片淫黄大片一级在线观看 | 毛片网 | 一级做a爰片性色毛片 |