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
Java Gradle-运行junit测试找不到我的xml文件_Java_Spring_Junit_Build_Gradle - Fatal编程技术网

Java Gradle-运行junit测试找不到我的xml文件

Java Gradle-运行junit测试找不到我的xml文件,java,spring,junit,build,gradle,Java,Spring,Junit,Build,Gradle,我有一个简单的junit测试任务 task testSanity(type: Test, dependsOn: testClasses) { def springInstrumentJarPath = project.configurations.compile.find { it.name.startsWith("spring- instrument") } jvmArgs '-javaagent:' + springInstrumentJarPath ex

我有一个简单的junit测试任务

task testSanity(type: Test, dependsOn: testClasses) {
    def springInstrumentJarPath = project.configurations.compile.find { it.name.startsWith("spring- instrument") }    
    jvmArgs '-javaagent:' + springInstrumentJarPath  
    exclude '**/*TimeBaseTest*'
    exclude '**/*SuiteTests*'
}
问题是我在以下位置为我的ehcache添加了一个新的xml文件:

/src/main/webapp/WEB-INF/classes/ehcache.xml
我所有的测试都失败了,因为junit找不到文件。 我如何在gradle任务中定义这一点


谢谢。

src/main/webapp
应该只包含Java代码中未使用的文件(更准确地说,是类加载器未加载的文件)。Java资源应该进入
src/main/resources
。因此,将文件移动到
src/main/resources/ehcache.xml应该可以解决问题。

通过p:configLocation=“classpath:/ehcache/ehcache.xml”修复,并将ehcache放在src/main/resources/ehcache/ehcache.xml中