https://github.com/spring-cloud/spring-cloud-config/issues/1777#issuecomment-750389679
Comment From: spencergibb
The only workaround is to not use multi-document files.
Comment From: kuberr
Spring boot itself handles multi-document .yml files gracefully by appending "(document #1)" etc. to each unique property source's name. It might be a bit naïve of me to ask, but can't this idea be implemented by the config server too?
Here is an example from the log trace, you can see the appended suffix when you scroll all the way to the right:
2021-01-14 13:54:28.232 TRACE 14956 --- [ main] o.s.b.c.config.ConfigDataEnvironment : Skipping inactive property source 'Config resource 'file [config\application.yml]' via location 'optional:file:./config/' (document #2)'
2021-01-14 13:54:28.247 TRACE 14956 --- [ main] o.s.b.c.config.ConfigDataEnvironment : Adding imported property source 'Config resource 'file [config\application.yml]' via location 'optional:file:./config/' (document #1)'
2021-01-14 13:54:28.247 TRACE 14956 --- [ main] o.s.b.c.config.ConfigDataEnvironment : Adding imported property source 'Config resource 'file [config\application.yml]' via location 'optional:file:./config/' (document #0)'
Comment From: spencergibb
This is already fixed
Comment From: ssgtcookie
The only workaround is to not use multi-document files.
Does this mean that the option to use multi-document files is dropped? I think this is one of the neat features in spring.
Comment From: spencergibb
That statement was to mean until the fix was deployed as part of 3.0.1. This is included in spring cloud 2020.0.2
Comment From: SweKast999
Using Multi document is not working as expected, I am using spring-cloud-config-server with version 3.1.8 and spring boot 2.7.6. I have 2 use cases where it is not working as expected.
### Usecase1:
application.yml
spring:
config:
import:
- classpath:/config/test.yml
test.yml
my:
prop1: default
prop2: default
---
spring:
config:
activate:
on-profile: dev
prop1: dev
prop3: abc
Now when I am running the config server using DEV profile, it is only returning me
prop1: dev
prop3: abc
and it is not giving me the common properties defined on the top (i.e my.prop1 and my.prop2). As you can see property names are unique. Can you tell me why the common properties are not included?
### Usecase2:
application.yml
spring:
config:
import:
- classpath:/config/integrations.yml
integrations.yml
emailProviders:
provider1:
apiKey: testKey
endpoint: testEndpoint
Now when I am running the config server using DEV profile, it is not returning me any properties. I am expecting apiKey and endpoint to be returned as they are common properties.
Now if I include on-profile: dev, I get the properties defined in DEV mode. I am not understanding what is happening. Can someone please help?