spring配置文件

来源:互联网 发布:数学书籍推荐 知乎 编辑:程序博客网 时间:2024/06/06 11:05

spring在启动是加载的配置文件默认的名称是applicationContext.xml如果你修改了名称或者xml文件存放的位置,那么需要在web.xml中配置一下。

<!-- spring配置文件。其他的比如springMVC的配置文件也是可以这样去配置配置文件的位置 -->
  <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:applicationContext-*.xml</param-value>
  </context-param>

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