使用@ContextConfiguration注解后,提示找不到配置文件
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注解后,提示找不到配置文件的更多相关文章
- 安装 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 后,有可能造成原本已安装的 ...
- python安装完毕后,提示找不到ssl模块的解决步骤
转载自 醇酒醉影 python安装完毕后,提示找不到ssl模块: [root@localhost ~]# python2.7.5 Python 2.7.5 (default, Jun 3 2013, ...
- python安装完毕后,提示找不到ssl模块的解决方示
python安装完毕后,提示找不到ssl模块: [root@localhost ~]# python2.7.5 Python 2.7.5 (default, Jun 3 2013, 11:08:43) ...
- 【lombok】使用lombok注解,在代码编写过程中可以调用到get/set方法,但是在编译的时候无法通过,提示找不到get/set方法
错误如题:使用lombok注解,在代码编写过程中可以调用到get/set方法,但是在编译的时候无法通过,提示找不到get/set方法 报错如下: 解决方法: 1.首先查看你的lombok插件是否下载安 ...
- 使用STS加入controller注解后编写程序无法自动提示
1.加入@Controller注解后编写程序无法自动提示,去掉了@Controller注解后就可以了! 2.解决方案:将@Controller替换为@RestController后,可以完美的 ...
- Robotframework ride ,运行后提示, [WinError 2] 系统找不到指定的文件。
运行后提示, [WinError 2] 系统找不到指定的文件. command: pybot.bat --argumentfile C:\Users\123\AppData\Local\Temp\RI ...
- javac编译后运行提示找不到或无法加载主类
第一种常见错误: package demo_01; public class hello { public static void main(String[] args) { System.out.p ...
- pyinstaller打包后运行提示找不到模块
截止到2017年9月20号,pyinstaller只支持到python3.5,如果需要支持到3.6,需要自己在github上下载pyinstaller的开发版. 在打包时候,并没有提示错误,可以顺利打 ...
- win10用户文件夹重命名,启用administrator账户,删除文件夹时提示找不到该项目
这一切都源自楼主洁癖一般的强迫症. 楼主在重置win10后的安装过程中用microsoft账户登录的电脑,发现用户文件夹名称怪怪的,于是想重命名一下.楼主发现重命名用户文件夹并不能简单地用F2搞定,于 ...
随机推荐
- 5.24 Declaring Attributes of Functions【转】
转自:https://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html 5.24 Declaring Attributes o ...
- Codeforces 735C:Tennis Championship(数学+贪心)
http://codeforces.com/problemset/problem/735/C 题意:有n个人打锦标赛,淘汰赛制度,即一个人和另一个人打,输的一方出局.问这n个人里面冠军最多能赢多少场, ...
- cat > 命令也可以创建文档
今天看<Linux/Unix系统编程手册>,发现用cat > 命令也可以直接创建文本文档: cat > testcatcreate.txttesttest [2]+ Stopp ...
- MAVEN安装过程
maven 的压缩包地址: http://pan.baidu.com/s/1kT4ckGf 第三方资源jar包地址: http://pan.baidu.com/s/1i3vtgED
- CentOS 配置solr中文分词器
第一步:使用IK-Analyzer.把分析器的文件夹上传到服务器. 第二步:需要把分析器的jar包添加到solr工程中. [root@bogon IK Analyzer 2012FF_hf1]# cp ...
- centOS6.5安装SUN-jdk7
一.下载SUN-JDK1.7.tar.gz文件他 地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1 ...
- (4)Redis 资料
Redis是一种面向“键/值”对类型数据的分布式NoSQL数据库系统,特点是高性能,持久存储,适应高并发的应用场景. Redis Home http://redis.io/ MSOpenTech/re ...
- TortoiseGit安装与配置
TortoiseGit 简称 tgit, 中文名海龟Git. 海龟Git只支持神器 Windows 系统, 有一个前辈海龟SVN, TortoiseSVN和TortoiseGit都是非常优秀的开源的版 ...
- C# 加载xml文档文件及加载xml字符串
//创建XmlDocument对象 XmlDocument xmlDoc = new XmlDocument(); //载入xml文件名 xmlDoc.Load(filename); //如果是xml ...
- mysql 常用操作指令
(1)centos mysql数据库文件在哪? [root@localhost ~]# find / -name mysql (2)查找数据库备份工具 mysqldump [root@localhos ...