日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring在3.1版本后的bean获取方法的改变

發布時間:2023/12/13 javascript 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring在3.1版本后的bean获取方法的改变 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

xml配置不變,如下

<?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-2.0.xsd"><bean id="test3" class="org.springframework.tests.sample.beans.TestBean" scope="prototype"><property name="name"><value>custom</value></property><property name="age"><value>25</value></property></bean></beans>

  

3.0版之前

獲取bean的方式是用 ??XmlBeanFactory

@Testpublic void beanTest(){Resource rs2 = new ClassPathResource("test.xml",AATest.class);BeanFactory bf = new XmlBeanFactory(rs2);TestBean tb2 = (TestBean)bf.getBean("test3");assertEquals("custom",tb2.getName());}

  

3.1版本之后,因為某些原因,XmlBeanFactory被拋棄了,如果再用的化,會顯示

The type XmlBeanFactory is deprecated

源碼里的測試方法里獲取bean的方法如下

@Testpublic void beanTest2(){Resource rs = new ClassPathResource("test.xml",AATest.class);;DefaultListableBeanFactory grandParent = new DefaultListableBeanFactory();new XmlBeanDefinitionReader(grandParent).loadBeanDefinitions(rs);TestBean tb = (TestBean) grandParent.getBean("test3");assertEquals("custom",tb.getName());}

?當然,也可以像下面這樣調用

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/qst/chapter08/bean.xml");Book book = (Book) context.getBean("book");

  

至于被拋棄的原因,如下

/*** Convenience extension of {@link DefaultListableBeanFactory} that reads bean definitions* from an XML document. Delegates to {@link XmlBeanDefinitionReader} underneath; effectively* equivalent to using an XmlBeanDefinitionReader with a DefaultListableBeanFactory.** <p>The structure, element and attribute names of the required XML document* are hard-coded in this class. (Of course a transform could be run if necessary* to produce this format). "beans" doesn't need to be the root element of the XML* document: This class will parse all bean definition elements in the XML file.** <p>This class registers each bean definition with the {@link DefaultListableBeanFactory}* superclass, and relies on the latter's implementation of the {@link BeanFactory} interface.* It supports singletons, prototypes, and references to either of these kinds of bean.* See {@code "spring-beans-3.x.xsd"} (or historically, {@code "spring-beans-2.0.dtd"}) for* details on options and configuration style.** <p><b>For advanced needs, consider using a {@link DefaultListableBeanFactory} with* an {@link XmlBeanDefinitionReader}.</b> The latter allows for reading from multiple XML* resources and is highly configurable in its actual XML parsing behavior.** @author Rod Johnson* @author Juergen Hoeller* @author Chris Beams* @since 15 April 2001* @see org.springframework.beans.factory.support.DefaultListableBeanFactory* @see XmlBeanDefinitionReader* @deprecated as of Spring 3.1 in favor of {@link DefaultListableBeanFactory} and* {@link XmlBeanDefinitionReader}*/ @Deprecated @SuppressWarnings({"serial", "all"}) public class XmlBeanFactory extends DefaultListableBeanFactory { //code...}

  

 

?

轉載于:https://www.cnblogs.com/lakeslove/p/7134191.html

總結

以上是生活随笔為你收集整理的Spring在3.1版本后的bean获取方法的改变的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 好吊一区二区三区视频 | 热久久中文 | 久久午夜无码鲁丝片午夜精品 | 欧洲精品久久久久毛片完整版 | 四虎在线看片 | 久热伊人| 亚洲二区中文字幕 | 亚洲精品国产成人无码 | 黄色一级视频 | 91免费短视频 | 美女一级黄 | 极品少妇xxxx | 精品久久二区 | 成人片在线视频 | 91黑丝美女 | 最新中文字幕第一页 | 国产一级二级视频 | 一区二区中文字幕在线观看 | 色呦呦一区二区三区 | 欧洲亚洲一区二区 | 手机在线精品视频 | 黄色a免费 | 日韩欧美中文字幕在线观看 | 成人免费看片39 | 国产私拍视频 | 黑白配高清国语在线观看 | 亚洲午夜精品一区二区三区 | 在线免费你懂的 | 少妇高潮视频 | 午夜亚洲aⅴ无码高潮片苍井空 | 中文字幕日韩在线播放 | 日韩欧美亚洲天堂 | 羞辱狗奴的句子有哪些 | 成人在线不卡视频 | 色综合网站 | 欧美特黄aaa| 久久午夜剧场 | 美女扒开粉嫩尿口 | 西川结衣在线观看 | 天天躁日日躁狠狠躁免费麻豆 | 成人毛片网| 一级片自拍 | 国产毛毛片 | 中文在线字幕免费观 | 午夜精品在线免费观看 | 亚洲国产精品自拍视频 | 99久久久久久久久久 | 水蜜桃色314在线观看 | 欧美乱视频 | 激情五月婷婷丁香 | 免费av在线网 | 亚洲国产精品毛片av不卡在线 | 男生和女生操操 | 人妻无码一区二区三区久久99 | 九九九九热 | 青青草逼 | 一区二区三区丝袜 | 欧美日韩三级 | 日韩免 | 国产成人欧美 | 99久久久国产精品免费蜜臀 | eeuss鲁片一区二区三区在线观看 | 久久精品国产精品亚洲 | 四虎com| 亚洲欲色| 欧美日韩亚洲另类 | 午夜男人天堂 | 欧美日一本 | 蜜桃中文字幕 | 日本少妇激情舌吻 | 天天插天天射 | 久精品免费视频 | 国产一级片网站 | 天天天av | 青青草国产成人99久久 | 狠狠干欧美 | 国产艳妇疯狂做爰视频 | 美女扒开让男人桶爽 | 国产一区 在线播放 | 91色影院 | a在线观看视频 | 老熟妇仑乱一区二区视频 | youjizz日韩| 成人在线观看h | 国产第页| 青青草超碰| 免费在线视频观看 | 精品无码一区二区三区在线 | 欧美精品 在线观看 | www.精品国产 | 91成人入口| 久久久久1| 婷婷久久久久 | 人人插人人看 | 成人久久在线 | 毛片网站视频 | 天天干天天草 | 麻豆精品视频免费观看 | 国产日韩专区 |