Skip to content

Active profiles set with spring.profiles.active in application.yml not being respected by Config Client version 3.0.0 #1781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iamdarkes opened this issue Jan 5, 2021 · 1 comment

Comments

@iamdarkes
Copy link

iamdarkes commented Jan 5, 2021

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
@iamdarkes iamdarkes changed the title Active profiles set with spring.profiles.active in application.yml not being respect by Config Client version 3.0.0 Active profiles set with spring.profiles.active in application.yml not being respect by Config Client version 3.0.0 Jan 5, 2021
@iamdarkes iamdarkes changed the title Active profiles set with spring.profiles.active in application.yml not being respect by Config Client version 3.0.0 Active profiles set with spring.profiles.active in application.yml not being respected by Config Client version 3.0.0 Jan 5, 2021
@ryanjbaxter
Copy link
Contributor

I believe this is a duplicate of #1777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants