接上一篇,导入项目后遇到的问题,

问题一:

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

提示找不到ApplicationContext.xml文件,网上找到答案:

使用maven创建web工程,将Spring配置文件applicationContext.xml放在src/resource下,用eclipse编译时提示class path resource [applicationContext.xml] cannot be opened because it does not exist错误。但是用mvn clean package命令编译时成功的。web.xml配置的如下

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

用google搜索一下(之前google用不了,用百度搜到蛋疼),发现是由于classpath不是指向resource路径,导致一直找不到文件。需要在classpath后面加个*,这样就解决问题了。

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param>

备注:需要改完所有的存在classpath的地方。

答案地址:https://blog.csdn.net/Mr_Pang/article/details/50854918

猜你喜欢

转载自www.cnblogs.com/hellohbx/p/12283116.html