gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:38:19 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com