码迷,mamicode.com
首页 > 移动开发 > 详细

解决 java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

时间:2019-09-16 21:18:44      阅读:368      评论:0      收藏:0      [点我收藏+]

标签:src   des   pom   http   filter   web项目   blog   rect   ring   

前几天好好运行的web项目突然跑不起来了

报这个错误

2019-09-16 19:18:29  [ RMI TCP Connection(3)-127.0.0.1:357 ] - [ ERROR ]  Context initialization failed

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

很显然,是找不到配置文件。

1、先考虑recourse目录下的配置文件路径是否正确。

  点击文件名可以跳转,排除这个原因。

2、检查生成的target/classes 文件下是否有配置文件。

  这是输出目录的主体,项目实际使用的配置文件就在里面。

  技术图片

 

没有找到配置文件。

 解决办法:在pom.xml中添加下面代码

<build>
        <resources>
            <resource>
                <directory>src/main/recourse</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
<directory></directory>路径根据自己的配置文件的路径而定。
<includes></includes>中的内容根据自己配置文件的种类而定。

技术图片

 

 成功。

 

参考博客:

https://blog.csdn.net/moneyshi/article/details/53287036

https://blog.csdn.net/yyym520/article/details/80516103

 

解决 java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

标签:src   des   pom   http   filter   web项目   blog   rect   ring   

原文地址:https://www.cnblogs.com/ditf/p/11529719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!