spring-boot - 测试 bootstrap.properties 中的 Spring Boot 2.2.4 未加载包含的 application.properties 配置文件
问题描述
从 2.1.6 升级到 Spring Boot 版本 2.2.4 时,我遇到了问题。
问题场景:
我有一个使用bootstrap-test.proeprties
and 测试作为活动配置文件的弹簧启动测试。bootstrap-test.properties
还包括一些由配置文件定义的其他配置application.properties
文件。
下面是示例代码:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT})
@ActiveProfiles("test")
public class SampleTest {
@Test
public void sampleTest() {
}
}
//bootstrap-test.properties
spring.profiles.include=db
application-db.properties
此处未加载文件中存在的属性并且测试失败。这在 spring-boot 版本 2.1.x 上运行良好。新靴子有什么变化吗
版本?
如果我将其更改bootstrap-test.properties
为application-test.properties
. 但是我仍然需要引导文件,因为我有需要在开始时加载的 Spring Cloud Config Server 属性。任何帮助表示赞赏。
解决方案
你用的是什么spring cloud版本?我们在升级到 boot 2.2.4 时也遇到了同样的问题。您应该将 spring cloud 版本升级到Hoxton.SR1
boot 2.2.4 。
推荐阅读
- python - RPI 在启动时打开终端并自动运行循环 python 脚本
- c++ - c ++程序计算字母字符的出现次数
- tkinter - 尝试使用 Tka11y
- java - string.split(\\s+) 无法处理前导空格
- python - 卸载用户在 macOS High Sierra 上使用 pip 安装的所有软件包
- php - 从标准 HTML 页面中访问 php 服务
- android - 应用程序在某些设备上显示默认图标,但在其他设备上不显示
- css - 使用 Img Materialise CSS 更改范围图标
- binary - 无符号二进制整数减法
- docker - 主机重启后 Docker 容器没有出现