1.web.xml文件配置

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:META-INF/spring/**/*.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

这里会加载所有的目录如META-INF/spring/**/*.xml的文件 

这里的contextConfigLocation就是告诉ContextLoaderListener去哪里加载。

配置了contextConfigLocation,就不会去加载/WEB-INF/下的applicationContext.xml,但是如果没有指定的话,默认会去/WEB-INF/下加载applicationContext.xml

 

2.注意:

如果配置成classpath*:applicationContext.xml,则会加入本项目及所有jar包根目录下的applicationContext.xml文件,跨jar包依赖时使用

但是如果是配置成classpath:applicationContext.xml,则只会加入本项目根目录下的applicationContext.xml文件,不依赖其它jar包的配置文件时可以这样写

相关文章:

  • 2021-12-26
  • 2021-06-25
  • 2022-01-17
  • 2022-02-08
  • 2022-01-01
  • 2021-11-26
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2021-07-25
  • 2022-02-25
相关资源
相似解决方案