spring - 在测试 Spring Boot 中加载不同的 application.yml
问题描述
我有一个问题,我无法在主要测试中加载 YML。我目前在路径中有一个application.ymlsrc > main > resources > config > application.yml
,我希望它采用src > test > resources > config > application-test.yml
我已经尝试过使用@ActiveProfiles("test")
,但走主要路线。我也试过@Profile("test")
,但没有什么不同。
我还尝试简单地在路径中创建application.ymlsrc > test > resources > config > application.yml
还要放注解:
@SpringBootTest(
properties = ["spring.profiles.active=test"],
classes = Application.class,
)
任何人都知道如何解决这个问题?
解决方案
推荐阅读
- java-8 - 出现错误:在 ANT 构建期间包 org.docx4j 不存在
- sql - Power BI:关系具有基数多对多问题
- inheritance - 适合案例的设计模式
- cypress - 无法将鼠标悬停在被另一个元素覆盖的菜单选项上
- html - 如何在 Html String 中给出相对图像路径?
- python-3.x - 使用 python3 代码单击 OK WinForm 按钮
- flutter - 如何将两个值与 List 的条目进行比较
- >?
- sql - 如何编写查询以获取具有 n 个连续日期的记录
- c++ - 为什么 CMake 从 INCLUDE_DIRECTORIES() 调用中删除一些包含目录?
- excel - 限制删除特定范围内的行