Spring 容器如何启动ApplicationContext.xml文件

Spring 容器如何启动ApplicationContext.xml文件,spring,struts,ioc-container,dao,Spring,Struts,Ioc Container,Dao,我已经用Struts实现了一个应用程序。我试图把它移到Spring,所以我一步一步地做每件事。第一个计划是实施国际奥委会(DI)。现在我修复了DAO,我修复了applicationContext.xml,当我尝试运行应用程序时(当然),它不会自动通过applicationContext.xml(有时称为beans.xml)为我创建bean。据我所知,我需要在服务类调用DAOs的方法之前初始化applicationContext.xml。Spring的IOC的正确流程是什么,或者容器如何启动App

我已经用Struts实现了一个应用程序。我试图把它移到Spring,所以我一步一步地做每件事。第一个计划是实施国际奥委会(DI)。现在我修复了DAO,我修复了applicationContext.xml,当我尝试运行应用程序时(当然),它不会自动通过applicationContext.xml(有时称为beans.xml)为我创建bean。据我所知,我需要在服务类调用DAOs的方法之前初始化applicationContext.xml。Spring的IOC的正确流程是什么,或者容器如何启动ApplicationContext.xml文件。

您是否向web.xml添加了所需的标记

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>

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

上下文配置位置
WEB-INF/applicationContext.xml
org.springframework.web.context.ContextLoaderListener

applicationContext.xml中有什么?你所有的bean定义?您的所有spring配置文件是否都在web.xml加载它们的类路径中?@Aahil Khan:您可以单击下面的复选框接受答案。