【问题标题】:Cant get Spring profile Groups working in application.yml无法获取在 application.yml 中工作的 Spring 配置文件组
【发布时间】:2022-01-23 14:35:30
【问题描述】:

我正在尝试让弹簧配置文件组工作,以便我可以同时运行两个配置文件。除了默认设置的 local 之外,其他 3 个配置文件 dev、qa 和 prod 由 Jenkins 作为 CI 的一部分使用一个 JenkinsFile 设置。这是我的 application.yml。

因此,需要同时运行两个关键配置文件。 @activatedProperties@ 将通过 Jenkins 进入,该配置文件用于设置所有 IP 布线和管道,用于进一步设置 Eureka。但我还需要将 awss3 设置为配置文件。如果您不使用 git 作为配置存储库,则必须将在这种情况下使用 awss3 的配置服务器配置设置为活动配置文件。

spring:
  profiles:
    active: @activatedProperties@
  # activatedProperties from jenkins will come in as local by default or dev, qa, prod
    group:
      local: "awss3"
      dev: "awss3"
      qa:  "awss3"
      prod:  "awss3"
  application: 
    name: HP-FETCHER-CONFIG-SERVICE
  

  cloud:
    config:
      server:
        awss3:
          bucket: hp-fetcher-config
          region: us-west-2
          order: 1

我想我没有以正确的方式使用配置文件组。

【问题讨论】:

    标签: spring-boot yaml


    【解决方案1】:

    这是设置个人资料组的正确方法

    spring:
      profiles:
        active: @activatedProperties@
        group:
          local:
          - "awss3"
          dev:
          - "awss3"
      application: 
        name: HP-FETCHER-CONFIG-SERVICE
    

    建议远离 Spring.cloud.config.server,尤其是作为 ECS 工作是一场噩梦。它只能作为一个不错的简单 localhost。

    【讨论】:

      猜你喜欢
      • 2019-05-19
      • 1970-01-01
      • 1970-01-01
      • 2022-10-04
      • 1970-01-01
      • 2019-04-06
      • 2016-06-07
      • 2019-02-21
      • 2017-05-01
      相关资源
      最近更新 更多