【问题标题】:Spring @ActiveProfiles no longer supports comma separated profilesSpring @ActiveProfiles 不再支持逗号分隔的配置文件
【发布时间】:2021-10-27 11:13:19
【问题描述】:

我们目前正在更新到 Spring Boot 2.4.8(Spring 5.3.8),我们的集成测试失败了。

经过长时间的调试,我发现我们的 @ActiveProfiles 注释不再适用于两个配置文件。我们定义如下:

@ActiveProfiles("dev,postgres")

但是,在新的 Spring Boot 版本中,它不再加载我们的 application-dev.yml 和 application-postgres.yml 文件。如果我将其定义如下,它会再次起作用:

@ActiveProfiles(value = {"dev", "postgres"})

这是一个已知的变化吗?因为我找不到任何关于它的信息。

【问题讨论】:

    标签: spring spring-boot spring-boot-test


    【解决方案1】:

    是的,这是一个已知的变化,非常烦人。

    它与 Spring Boot 2.3 一起提供,但我不能说出确切的版本。

    另一方面,ActiveProfiles 的值始终是一个数组,因此支持的逗号分隔值是错误的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-28
      • 1970-01-01
      • 1970-01-01
      • 2011-08-20
      • 1970-01-01
      相关资源
      最近更新 更多