Closed danparisi closed 2 years ago
I fixed the behavior by adding the following EnvironmentPostProcessor:
public class ConsulConfigEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
var customProperties = new Properties(1);
customProperties.setProperty("spring.config.import", "optional:consul:consul:8500/");
var ps = new PropertiesPropertySource("custom-resource", customProperties);
environment.getPropertySources().addLast(ps);
}
@Override
public int getOrder() {
return HIGHEST_PRECEDENCE;
}
}
P.S. Don't forget to register it in your spring.factories:
org.springframework.boot.env.EnvironmentPostProcessor=\
eu.dimoco.hub.gateway.ConsulConfigEnvironmentPostProcessor
I'm having this bug after upgrading:
Involved actors are:
I'm expecting my services to load the configuration in this order (higher on top in the following list):
In common-library/resources/application.yml I've:
It seems that property keys are always overridden only from the ones from service-profile.yml from consul and not from servicename.yml. Keys from servicename.yml are only able to override the ones from the application.yml from the common-library.
The idea is that consul properties should always have the higher precedence over the configuration files in the classpath.