java - Junit 测试在 Eclipse 中运行但失败并显示 `gradle test`

标签 java spring spring-boot testing integration-testing

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

相关文章:

java - 将从一个响应中获取的 sessionId 传递给下一个请求

java - 如何使用注释在 Spring MVC 中创建默认方法?

java - 动态 Javafx View 的 Controller 类

java - 运行循环后,如何清除屏幕以便每个循环都显示在空白控制台上?

java - 根据条件比较数组列表中的对象字段值,如果条件为真则删除

java - 按用户条件在 JSP 中渲染

java - 如何使用 RSA 私钥解密 JWT

Spring Feign 不压缩响应

java - 将 CrudRepository 中发出的命令转换为函数时出现问题

java - 线程局部变量是否需要是静态的才能造成内存泄漏