【问题标题】:configuring profile specific spring-cloud-consul properties配置配置文件特定的 spring-cloud-consul 属性
【发布时间】:2016-07-12 00:36:00
【问题描述】:

我正在使用spring-cloud-starter-consul-config'. For this I defined my properties inbootstrap.yml. But I need to use profile specific consul properties which is not working inbootstrap.yml`。

我还需要使用自定义属性文件而不是bootstrap.yml,以便我可以使用@PropertySource 加载此自定义文件。有什么想法吗?

@SpringBoogApplication
@EnableAutoconfiguration
public class myApplication {
}

bootstrap.yml

environments:
  dev:
      spring:
        cloud:
          consul:
            host: dev-consul
            port: 8500

【问题讨论】:

  • 您不能将这些属性放在 application-{env}.yml 文件中吗?所以它通过传递给应用的配置文件加载它们?
  • bootstrap-dev.yml 有效吗?如果没有,您可以在一个文件中定义多个 yaml 文档,请查看 spring boot 文档。

标签: spring properties configuration spring-cloud


【解决方案1】:

创建第二个application-{env}.ymlbootstrap-{env}.yml 文件。

然后构建jar并启动java -jar app.jar -Dspring.profiles.active={env}

【讨论】:

    猜你喜欢
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-14
    • 2017-12-10
    • 2015-01-03
    • 2017-05-27
    相关资源
    最近更新 更多