Add support of Multi-document property files and Activation Properties in spring cloud config.
I have an example project to reproduce the problem
config server application.properties
spring.profiles.active=native
server.port=8888
test.property=test
test.other=test2
#---
spring.config.activate.on-profile=dev
test.property=dev
when I try to read config from config properties for profile dev both property sources is returned, but both of them has the same name, and this could be one of the problem
curl http://localhost:8888/application/dev
{
"name":"application",
"profiles":[
"dev"
],
"label":null,
"version":null,
"state":null,
"propertySources":[
{
"name":"classpath:/application.properties",
"source":{
"spring.config.activate.on-profile":"dev",
"test.property":"dev"
}
},
{
"name":"classpath:/application.properties",
"source":{
"spring.profiles.active":"native",
"server.port":"8888",
"test.property":"test",
"test.other":"test2"
}
}
]
}
On client side because the propertySources has the same name, the propertySources is overriden.
-
If we do with legacy bootstrap implementation the first property source is present in environment
-
If the application is started with
spring.config.import=optional:configserver:http://localhost:8888
the second property source is present in environment
Comment From: ryanjbaxter
Just to be clear, this problem does not occur when using the legacy bootstrap implementation, correct? The property sources have two different names?
Comment From: anghel86
Both implementation had this problem. I'm expecting both property sources to be loaded in client environment, but because of the name only one is loaded, in case ob legacy bootstrap the first one is loaded with "on-profile" property, in case of new impl the default property source is loaded in environment
Comment From: ryanjbaxter
OK I wanted to make sure it was not a regression in functionality. Thanks
Comment From: ryanjbaxter
I can no longer reproduce this using Spring Boot 2.7.5 and Spring Cloud 2021.0.5, please try the latest GA releases and reopen if you can reproduce it