关于java:Junit测试在Eclipse中运行,但由于“ gradle test”失败

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

我正在使用Spring Boot 2,并且正在尝试进行集成测试。
我通过以下方式配置了自定义application.properties

1
2
3
4
@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,则默认文件具有优先级,并且已加载而不是测试文件。