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

前几天好好运行的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

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

时间: 2024-08-28 20:06:06

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

Caused by: java.io.FileNotFoundException: class path resource [mappers/*.xml] cannot be opened because it does not exist

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsa

Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be ope

1.错误描述 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) at org.springframework.test.context.DefaultTestContext.

parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not e

控制台异常: parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not exist 报错原因是 xml名字可能写错了 原文地址:https://www.cnbl

java.io.FileNotFoundException: class path resource [XXXXX.xml] cannot be opened

java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exit. 在用maven管理的spring项目中做单元测试时候,加载不了spring的配置文件.出现该问题的原因是,用maven创建的项目,必须把spring的配置文件beans.xml或者applicationContext.xml放到系统根目录下,做单元测试时候用 ApplicationCon

nested exception is java.io.FileNotFoundException: class path resource [spring-mybatis.xml] cannot be opened

idea+maven+springmvc项目,做单元测试报错,找不到配置文件. @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:spring-mybatis.xml"}) public class TestMybatis { private static Logger logger = LoggerFactory.getLogger(TestMybatis.cla

class path resource [applicationContext.xml] cannot be opened because it does not exist

今天给游戏管理端添加新功能,启动时报错 Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist 找不到文件 1.查看项目资源目录,applicationContext.xml  位于conf下 2.查看applicationContext.xml 的配置 3.查看项目classpath配置,没有

解决CXF的java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist

以下是错误信息 九月 25, 2017 8:22:04 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh 信息: Refreshing Root WebApplicationContext: startup date [Mon Sep 25 20:22:04 CST 2017]; root of context hierarchy 九月 25, 2017 8:22:04 下午 or

nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog

spring单元测试时发现的问题: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/spring-datasource-mogon.xml]; nested exception is java.io.FileNotFoundException: class path resource [

cxf(3.1.1) 异常Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml]

Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist用的最新版本,这个版本中 cxf-extension-soap.xml 不需要了直接在配置文件中删除即可 现在只需要引两个文件 <import resource="classpath:META-INF/cxf/