在 Eclipse 中进行 Junit 测试 运行 但因“gradle 测试”而失败

Junit test run in Eclipse but fails with `gradle test`

我正在使用 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

怎么回事?

好的,我将 属性 文件放在 src/test/resources 下,并将该文件夹添加到 Eclipse 中的构建路径。

PS: 我之前的回答是错误的。如果我将文件命名为 application.properties,则默认文件具有优先权并加载它而不是测试文件。