我正在使用 Spring Boot 2 并且正在尝试进行集成测试。
我以这种方式配置了自定义 application.properties
:
@TestPropertySource(
locations = "classpath:###/$$$/application-integrationtest.properties"
)
@ComponentScan(basePackages = { "###.$$$" })
文件位于src/test/java/###/$$$/application-integrationtest.properties
在 Eclipse 下运行 Junit 工作正常,但如果我尝试 gradle test
,我得到:
java.io.FileNotFoundException: class path resource [###/$$$/application-integrationtest.properties] cannot be opened because it does not exist
这是怎么回事?
最佳答案
正在关注 JB Nizet's comment我将我的属性文件放在 src/test/resources
下,并将该文件夹添加到 Eclipse 中的构建路径。
关于java - Junit 测试在 Eclipse 中运行但失败并显示 `gradle test`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55297676/