【问题标题】:spring boot multi-profile configuration reads property from different profilespring boot 多配置文件配置从不同配置文件中读取属性
【发布时间】:2017-05-14 23:51:02
【问题描述】:

我正在添加多配置文件外部配置,如 我的application.ymldocumentation所示

   spring:
      profiles:
        active: prod
    server:
      context-path: '/webAppName'
      port: 8989

    ---
    spring:
      profiles: prod

    executor-names:
      - wasTaskExecutor=wm/default
      - taskExecutorUWS=wm/default_uws

    ---
    spring:
      profiles: qa

    datacollector:
        jndi-name: jdbc/qaCipDs

    ---
    spring:
      profiles: dev

    ruleapp-dir: res_data

    executor-names:

在我正在检查的代码中,如果ruleapp-dir 不为空,则执行dev 特定代码块。

当我运行时,我注意到executor-names 填充正确,但ruleapp-dir 也被映射到res-data,就像在dev 配置文件中一样。 注意:我通过访问 environment.getactiveprofiles 来完成这项工作,但想知道为什么 ruleapp-dir 仅存在于 dev 配置文件中时会获得一个值。

【问题讨论】:

    标签: spring spring-boot yaml


    【解决方案1】:

    我的猜测是删除profiles: devruleapp-dir: res_data 之间的额外行可能值得

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-28
      • 2021-11-27
      • 2017-12-21
      • 2018-07-07
      • 2020-05-07
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      相关资源
      最近更新 更多