问题描述:
SpringMVC项目添加ContextLoaderListener后无法启动,
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
报错信息为:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/<NONE>]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/<NONE>]
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
解决方案:
在web.xml中加入<context-param>并指定spring配置文件
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext.xml</param-value>
</context-param>