众所周之,spring源码解析之默认配置文件名/WEB-INF/applicationContext.xml。但是这个是在spring源代码里记录的呢?
今天就抱着试一试的态度去找到答案。
首先查看工程中的 web.xml,其中配置 spring的代码如下
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
<description>Spring配置文件初始化WebApplicationContext</description>
<contextClass></contextClass> <!-- 自定义 -->
</context-param>
<!-- spring 配置 对应的是 [org.springframework.web] 属于spring-web JAR包 applicationContext.xml 汇总多个 配置文件-->
<!-- spring 装载器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
其中 参数名 contextConfigLocation 就是描述spring配置文件初始化的位置。