Set profile on bootstrap.yml in spring cloud to target different config server Set profile on bootstrap.yml in spring cloud to target different config server docker docker

Set profile on bootstrap.yml in spring cloud to target different config server


I find the solution. Basically, we use spring profile to enrich the bootstrap file. For example

spring:  application:    name: myservice  cloud:    config:      uri: http://config:8890      fail-fast: true---spring:  profiles: development  cloud:    config:      uri: http://localhost:8890

The good news is that we don't have to rewrite all properties in a profile. The default properties are inherited. For instance, when the development profile is enabled, my application name is inherited from the default one called always myservice.

To activate the profile, start the service with the following property

-Dspring.profiles.active=development