Java Gradle-运行junit测试找不到我的xml文件
我有一个简单的junit测试任务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
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中