java - 是否需要 bootstrap.yml?
问题描述
我有一个带有注释的测试类
@SpringBootTest.
@ActiveProfiles("default")
原来有一个bootstrap.yml文件,内容如下
spring:
application:
name: [insert name]
cloud:
config:
enabled: false
vault:
enabled: false
我想将 bootstrap.yml 的内容移动到 application-default.yml 并删除 bootstrap.yml,但这会导致测试失败。这是可能的吗?
解决方案
尝试使用此注释:
@TestPropertySource(locations = "classpath:application-default.yml")
只需确保您的 application-default.yml 在资源粘贴上。
推荐阅读
- python - 计算用 python 编码的 BMI 时出错
- angular - 在 Angular 6 中编译 HTML
- gtk3 - 更新 gtk_tree_view 中的行
- c# - ManagementObjectSearcher 不包含 Get 的定义
- python - 当py文件动态创建和命名数据文件并在运行启动后读取它们时,如何使用pyinstaller将py文件制作为exe?
- c - 如何在C中分配多维数组所需的内存?
- docker - 使用裸机服务器开始使用 docker swarm
- javascript - 加载时的路由在我的 React 本机应用程序上不起作用
- go - 如何制作一个接收自定义接口数组的函数
- dsl - Xtext 语法错误“cannot find type for [State]”即使有这样的类型也会抛出