在Intellij中运行测试时,如何指定Spring Boot配置文件

发布于 2025-02-10 20:24:19 字数 291 浏览 1 评论 0原文

使用Intellij,我可以指定启动服务时运行的弹簧启动配置文件

但是,如果我运行MVN CLEAN install,则使用默认配置文件运行测试,这会导致它们失败。如何告诉MVN使用特定的弹簧启动配置文件运行测试?

With IntelliJ, I can specify a Spring boot profile to run when starting a service
enter image description here

However, if I run mvn clean install, then the tests are run with the default profile, which causes them to fail. How can I tell mvn to run the tests with a specific Spring Boot profile?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是偏爱你 2025-02-17 20:24:20

创建/定义属性文件,然后将其放入您的src/test/Resources文件夹中。

使用类级别注释@ActiveProfiles并指定您的属性文件名,例如@ActiveProfiles(“ myproperties”)

希望这会有所帮助!

Create/define a properties file and put it within your src/test/resources folder.

Use class level annotation @ActiveProfiles and specify your property file name like this @ActiveProfiles("myProperties")

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文