配置特定于配置文件的spring-cloud-consul属性

时间:2016-03-24 12:10:13

标签: spring properties configuration spring-cloud

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

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

@SpringBoogApplication
@EnableAutoconfiguration
public class myApplication {
}

bootstrap.yml

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

1 个答案:

答案 0 :(得分:1)

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

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

相关问题