Spring项目没有创建spring-config.xml

时间:2013-08-02 20:47:03

标签: spring spring-mvc

我已经阅读了一些关于使用spring的教程,我看过他们谈到“spring-config.xml”,但是当我创建一个项目时我没有那个文件,我有“application-config.xml” “,他们是一样的吗?前者是后者的更新版本吗?我使用Eclipse作为IDE

1 个答案:

答案 0 :(得分:1)

Spring Context仅定义了创建Spring配置的概念,您将在其中定义spring组件(bean,服务等)

XML本身可以根据需要进行命名,但是在web.xml文件中,您必须将您选择的xml名称传递给spring上下文侦听器

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

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