configuring profile specific spring-cloud-consul properties

Viewed 1381

I am using 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`.

Also I need to use custom property file instead of bootstrap.yml so that i can load this custom file using @PropertySource. Any idea?

@SpringBoogApplication
@EnableAutoconfiguration
public class myApplication {
}

bootstrap.yml

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

Create second application-{env}.yml and bootstrap-{env}.yml files.

Then build jar and start java -jar app.jar -Dspring.profiles.active={env}

Related