Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法打开Spring JUnit ContextConfiguration类路径资源_Spring_Junit_Spring Boot_Spring Test - Fatal编程技术网

无法打开Spring JUnit ContextConfiguration类路径资源

无法打开Spring JUnit ContextConfiguration类路径资源,spring,junit,spring-boot,spring-test,Spring,Junit,Spring Boot,Spring Test,我正在gradle项目中使用最新版本的SpringBoot(SpringBootStarterWeb和test)。我以前使用的这个旧的单元测试已经不起作用了 XML上下文文件位于src/test/resources/myTestContext.XML下。但是,当我尝试在Eclipse(mars 4.5)中作为Junit测试运行此测试时,出现了以下错误 src/test/resources在您的类路径中吗?在eclipse中,如果我转到project->properties->java构建路径,我

我正在gradle项目中使用最新版本的SpringBoot(SpringBootStarterWeb和test)。我以前使用的这个旧的单元测试已经不起作用了

XML上下文文件位于src/test/resources/myTestContext.XML下。但是,当我尝试在Eclipse(mars 4.5)中作为Junit测试运行此测试时,出现了以下错误


src/test/resources
在您的类路径中吗?在eclipse中,如果我转到project->properties->java构建路径,我会看到列出了src/test/resources。您是否在没有“/”的情况下尝试过它?删除起始/并添加类路径:
@ContextConfiguration(locations={"/myTestContext.xml"})
public class MyTest extends AbstractJUnit4SpringContextTests{
....


Caused by: java.io.FileNotFoundException: class path resource [myTestContext.xml] 
cannot be opened because it does not exist at     
org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) ~[spring-core-4.1.7.RELEASE.jar:4.1.7.RELEASE]