当前位置: 首页 > 知识库问答 >
问题:

在IntelliJ Community 2017.1中运行spring boot测试时出错

轩辕远
2023-03-14

这是一种非常怪异的行为。我有一个spring boot应用程序工作良好。自从几天以来(我刚刚将应用程序切换到另一个Git repo(如果这意味着什么的话)),每次我用IntelliJ运行测试时,我都会发现错误:

null

所以它说它找不到我在这里声明的test.properties文件:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MyApplication.class)
@TestPropertySource(locations="test.properties")
@SpringBootTest
public class AudioVideoControllerTest {...}

该文件位于类路径(src/main//com/mycompany/myproject/test.properties)中

最奇怪的是。如果我用Eclipse(实际上是Sprig工具套件)打开项目并运行测试,它们就能工作。然后我又对IntelliJ进行了测试...他们起作用了!

因此,当我打开并刷新项目时,Eclipse/STS似乎做了一些更改,但我想知道它是什么。

共有1个答案

端木明贤
2023-03-14

解决方案是将test.properties文件拖到另一个文件夹中,让IntelliJ更新引用,然后再次将test.properties文件移回根文件夹,再让IntelliJ更新所有引用。

 类似资料: