首页 > 解决方案 > 是否需要 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,但这会导致测试失败。这是可能的吗?

标签: javaspringspring-bootyaml

解决方案


尝试使用此注释:

@TestPropertySource(locations = "classpath:application-default.yml")

只需确保您的 application-default.yml 在资源粘贴上。

编辑:看看 https://stackoverflow.com/a/26840503/11329776


推荐阅读