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

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

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

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

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

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

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
相關文章:
主站蜘蛛池模板: 久草在在线| 伊人久久青草青青综合 | 国产女女视屏免费 | 国产在线毛片 | 国产精品露脸脏话对白 | 欧美在线一区二区三区 | 久草免费福利 | 欧美另类性视频在线看 | 欧美亚洲国产成人不卡 | 美女张开腿给男生桶下面视频 | 国产精品9999久久久久 | 国产呦精品系列在线 | 免费看片aⅴ免费大片 | 午夜嘿咻 | 香蕉香蕉国产片一级一级毛片 | 国产精品正在播放 | 日韩免费观看一级毛片看看 | 国产香蕉久久 | 性做久久久久久 | 久操影视 | 久草草视频在线观看免费高清 | 澳门毛片免费观看 | 成人欧美视频 | 欧美另类videosbestsex久久 | 久久狠狠色狠狠色综合 | 国产精品久久久久一区二区三区 | 波多野结衣在线看片 | a毛片免费全部播放完整成 a毛片免费全部在线播放毛 | 亚洲视频在线免费 | 99在线精品免费视频九九视 | 国产欧美一区二区三区观看 | 久久国产精品久久 | 一个人看的www日本视频 | 日韩欧美一区二区中文字幕 | 96精品视频在线播放免费观看 | 久草在线观看首页 | 青青爽国产手机在线观看免费 | 欧美一级毛片欧美一级成人毛片 | 亚洲精品一区二区三区网址 | 国产高清天干天天视频 | 免费成年网站 |