簡體   English   中英

春季:-如果從web.xml加載上下文,我們如何獲得Bean?

[英]Spring: - How can we get Bean if context are loaded from web.xml?

我正在學習在項目中使用的spring 。我在web.xml中找到了contextConfigLocation條目

 /WEB-INF/context/*-context.xml
 classpath:/context/database-context.xml
 classpath:/context/database-service-context.xml
 classpath:/context/business-process-management-service-context.xml

和聽眾

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

在一個我讀如下的核心項目中

 Resource r=new ClassPathResource("applicationContext.xml");  
 BeanFactory factory=new XmlBeanFactory(r);  
 Employee s=(Employee)factory.getBean("e"); 

但是無法弄清楚事情是如何工作的以及在何處調用getBean()函數嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM