org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
错误释义:
org.springframework.beans.factory。BeanDefinitionStoreException: IOException解析来自ServletContext资源的XML文档[/WEB-INF/applicationContext.xml];嵌套异常是java.io。FileNotFoundException:无法打开ServletContext资源[/WEB-INF/applicationContext.xml]
分析的代码所处:
原因:spring的监听器只要配置了加载监听器的类,下面就必须设置配置文件的路径,不可以不写。
<!-- 配置spring的监听器,2大组件默认只加载WEB-INF目录下的applicationContext.xml配置文件 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 设置配置文件的路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>