intellij提示找不到配置文件

错误代码如下:

严重: Caught exception ]
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:)
    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$.runReflectiveCall(SpringJUnit4ClassRunner.java:)
    at org.junit.)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:)
    at org.junit.runners.ParentRunner$.run(ParentRunner.java:)
    at org.junit.runners.ParentRunner$.schedule(ParentRunner.java:)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:)
    at org.junit.runners.ParentRunner.access$(ParentRunner.java:)
    at org.junit.runners.ParentRunner$.evaluate(ParentRunner.java:)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:)
    at java.lang.reflect.Method.invoke(Method.java:)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [test/spring-idol.xml]; nested exception is java.io.FileNotFoundException: class path resource [test/spring-idol.xml] cannot be opened because it does not exist
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:)

目录结构:

源代码:

@ContextConfiguration("spring-idol.xml")
public class AspectTest {
    @Autowired
    ApplicationContext context;

    @Test
    public void audienceShouldApplaud() throws Exception {
//        ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("spring-idol.xml");
        Performer eddie = (Performer) context.getBean("eddie");
        eddie.perform();
    }

解决方案:

更改@ContextConfiguration注解内容为

@ContextConfiguration("classpath*:/spring-idol.xml")

或为

@ContextConfiguration("../spring-idol.xml")

或者
将配置文件放在resources/test目录下。

使用@ContextConfiguration注解后,提示找不到配置文件的更多相关文章

  1. 安装 VS 2015 Update 2 + Windows SDK Tools 1.3.1 + Windows SDK 10586.212 后提示找不到 10586.0 SDK 问题的解决方法

    将 Visual Studio 2015 升级到 Update 2,并安装 Windows SDK Tools 1.3.1 和 Windows SDK 10586.212 后,有可能造成原本已安装的 ...

  2. python安装完毕后,提示找不到ssl模块的解决步骤

    转载自 醇酒醉影 python安装完毕后,提示找不到ssl模块: [root@localhost ~]# python2.7.5 Python 2.7.5 (default, Jun 3 2013, ...

  3. python安装完毕后,提示找不到ssl模块的解决方示

    python安装完毕后,提示找不到ssl模块: [root@localhost ~]# python2.7.5 Python 2.7.5 (default, Jun 3 2013, 11:08:43) ...

  4. 【lombok】使用lombok注解,在代码编写过程中可以调用到get/set方法,但是在编译的时候无法通过,提示找不到get/set方法

    错误如题:使用lombok注解,在代码编写过程中可以调用到get/set方法,但是在编译的时候无法通过,提示找不到get/set方法 报错如下: 解决方法: 1.首先查看你的lombok插件是否下载安 ...

  5. 使用STS加入controller注解后编写程序无法自动提示

    1.加入@Controller注解后编写程序无法自动提示,去掉了@Controller注解后就可以了! ​ ​ 2.解决方案:将@Controller替换为@RestController后,可以完美的 ...

  6. Robotframework ride ,运行后提示, [WinError 2] 系统找不到指定的文件。

    运行后提示, [WinError 2] 系统找不到指定的文件. command: pybot.bat --argumentfile C:\Users\123\AppData\Local\Temp\RI ...

  7. javac编译后运行提示找不到或无法加载主类

    第一种常见错误: package demo_01; public class hello { public static void main(String[] args) { System.out.p ...

  8. pyinstaller打包后运行提示找不到模块

    截止到2017年9月20号,pyinstaller只支持到python3.5,如果需要支持到3.6,需要自己在github上下载pyinstaller的开发版. 在打包时候,并没有提示错误,可以顺利打 ...

  9. win10用户文件夹重命名,启用administrator账户,删除文件夹时提示找不到该项目

    这一切都源自楼主洁癖一般的强迫症. 楼主在重置win10后的安装过程中用microsoft账户登录的电脑,发现用户文件夹名称怪怪的,于是想重命名一下.楼主发现重命名用户文件夹并不能简单地用F2搞定,于 ...

随机推荐

  1. 对比其它软件方法评估敏捷和Scrum

    一般来说,选择一种软件开发方法,更像是加入一个邪教组织,而不像是做出了一个技术决策.许多公司甚至从未试图去评估这些方法,而仅仅是盲目采用最流行的方法,这就造成了如今五花八门的各种敏捷方法.因此本文将使 ...

  2. Aspose.Words操作word生成PDF文档

    Aspose.Words操作word生成PDF文档 using Aspose.Words; using System; using System.Collections.Generic; using ...

  3. IE11打不开网页, 所有菜单都被禁用了。

    估计是安装完PPS之后,PPS安装程序附加了一些加载项到浏览器,而我在安装时强制禁用了它的加载项引起的. 解决方法是重置IE设置,命令为:inetcpl.cpl,点击高级选项卡的重置即可.

  4. oracle监听服务无法打开

    原因: 修改了主机名,但没有修改监听文件listener.ora里面的配置. 解决办法:修改HOST与主机名相同 LISTENER = (DESCRIPTION_LIST = (DESCRIPTION ...

  5. 快速稳定的维护PHP

    Just to recap, previously we'd have this sort of thing: namespace me\adamcameron\testApp; use Guzzle ...

  6. Eclipse中Outline里各种图标的含义

    在使用Eclipse或者MyEclipse开发的时候,你一定看到过Outline和Package Explorer中小图标,很多刚刚接触编程的童鞋们可能不会在意它们代表的含义,但如果你花几分钟的时间了 ...

  7. js认清this的第一步

    学习 this 的第一步是明白 this 既不指向函数自身也不指向函数的词法作用域, 你也许被这样的解释误导过, 但其实它们都是错误的.this 实际上是在函数被调用时发生的绑定, 它指向什么完全取决 ...

  8. JavaScript脚本语言基础(一)

    导读: JavaScript代码嵌入HTML文档 JavaScript代码运行方式 第一个实例 JavaScript的三种对话框 定义JavaScript变量 JavaScript运算符和操作符 Ja ...

  9. 求两个数的最大公约数(Java)

    获得两个随机数(100以内),并放入数组中 public int[] getTwoRandom(){ int[] t = new int[2]; Random rand = new Random(); ...

  10. python 运行python manege.py runserver时报错:“no module named djangorestframework” 的解决方案

    python 运行python manege.py runserver时报错:“no module named djangorestframework” 的解决方案 importerror:no mo ...