色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術文章
文章詳情頁

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

瀏覽:3日期: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可以關閉容器,可以調用close()方法,關閉容器,調用銷毀方法

3.對象延時實例化對多例模式沒有意義。

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(); }

通過構造完成初始bean屬性,可以通過初始化完成

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

標簽: Spring
相關文章:
主站蜘蛛池模板: 欧美一级在线毛片免费观看 | 久久国产精品久久精品国产 | 岛国在线免费观看 | 天干夜天天夜天干天ww | 成年人网站在线观看视频 | 成人男女网18免费91 | 亚洲日本综合 | 国产亚洲高清在线精品不卡 | 亚洲成a人片在线观看中 | 欧美人成在线视频 | 欧美成人免费在线视频 | yy6080福利午夜免费观看 | 成人综合网址 | 玖玖精品在线视频 | 国产99视频精品免视看9 | 国产萌白酱在线一区二区 | 孕妇孕妇aaaaa级毛片视频 | 国产大陆精品另类xxxx | 亚洲国产毛片aaaaa无费看 | 最新国产精品好看的国产精品 | 欧美成人免费全网站大片 | 国内精品久久久久久久久蜜桃 | 久久狠狠躁免费观看2020 | 日产一区两区三区 | 欧美大屁股精品毛片视频 | 亚洲天堂中文网 | 日韩精品一区二区三区 在线观看 | 免费一级a毛片在线播放视 免费一级α片在线观看 | 奶交性视频欧美 | 亚洲一区二区三区久久精品 | 亚洲成人7777 | 日韩欧美一区二区三区免费观看 | 亚州免费视频 | 午夜性爽视频男人的天堂在线 | 国产欧美日韩亚洲精品区2345 | 成人精品在线观看 | 欧美精品成人一区二区在线观看 | 欧美黄网站免费观看 | 亚洲不卡一区二区三区在线 | 免费国产a| 成年男人午夜片免费观看 |