Spring Mvc java.io.FileNotFoundException – ApplicationContext.xml
applicationContext.xml在WEB-INF文件夹中,为什么我收到此错误:
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
在web.xml
org.springframework.web.context.ContextLoaderListener log4jConfigLocation /WEB-INF/classes/log4j.properties org.springframework.web.util.Log4jConfigListener org.springframework.web.context.ContextLoaderListener crimetrack org.springframework.web.servlet.DispatcherServlet 1 crimetrack *.htm index.jsp /spring /WEB-INF/tld/spring-form.tld
在我的情况下,我需要做的就是从中移动 applicationContext.xml
src\main\webapp\WEB-INF\
至
src\main\resources\
。
我不得不坚持使用WEB-INF文件中的/ resources目录,或者你可以任意命名。 类路径查看WEB-INF目录,但它会扫描该目录中的文件夹。 我将applicationContext.xml和servlet.xml文件移动到WEB-INF / resources目录中,因此可以从WEB-INF的根目录中删除它,并且不需要维护applicationContext.xml的两个副本或者servlet.xml文件。