using org.springframework.cloud:spring-cloud-starter-config
springCloudVerson 2020.0.0
which importsorg.springframework.cloud:spring-cloud-starter-config:3.0.0
I made new projects using Spring Initializr for Config Client and Config Server. spring.profiles.active
property is ignored by Config Client and the profile default
is all that's used. I see in org/springframework/cloud/config/client/ConfigServerConfigDataLocationResolver.class
protected ConfigClientProperties loadProperties(ConfigDataLocationResolverContext context) {
Binder binder = context.getBinder();
BindHandler bindHandler = getBindHandler(context);
ConfigClientProperties configClientProperties = binder
.bind(ConfigClientProperties.PREFIX, Bindable.of(ConfigClientProperties.class), bindHandler)
.orElseGet(ConfigClientProperties::new);
String applicationName = binder.bind("spring.application.name", Bindable.of(String.class), bindHandler)
.orElse("application");
configClientProperties.setName(applicationName);
return configClientProperties;
}
The issue seems to be the ConfigServerConfigDataLocationResolver
receives the active profiles via the ConfigDataLocationResolverContext
but doesn't set the profile on the ConfigClientProperties
instance.
Starting the app results in conflicting log statements. Where the application environment logs the new profile dev
while the Spring Cloud environment logs the profile default
.
2021-01-04 16:44:44.248 INFO 68447 --- [ main] m.d.client.ClientApplicationKt : The following profiles are active: dev
2021-01-04 16:44:44.285 INFO 68447 --- [ main] o.s.b.context.config.ConfigDataLoader : Fetching config from server at : http://localhost:8888
2021-01-04 16:44:44.285 INFO 68447 --- [ main] o.s.b.context.config.ConfigDataLoader : Located environment: name=client, profiles=[default], label=null, version=17e7a5825eb6a7f2dbb42003fd8c97261bf8250e, state=null
Comment From: ryanjbaxter
I believe this is a duplicate of https://github.com/spring-cloud/spring-cloud-config/issues/1777