前幾天好好運行的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