I am having an issue with spring boot 2.4.1 (also 2.4.2) when loading configuration from consul using the new import mechanism (spring.config.import=consul:). Everything in regard to getting the external data is working but the logic is not as stated in the docs here https://docs.spring.io/spring-cloud-consul/docs/3.0.0/reference/html/#config-data-import

Running with the default profile, the config contributors has wrong order, it overrides the application specific values with the defaultContext values instead of the opposite.

After investigating a bit, this issue doesn't seem to be only a consul problem but a general external configuration problem. Seems like the root cause for this is that ConfigDataImporter traverse candidates in reverse order and therefore we get the opposite order for property sources for a given candidate, consul property sources in my case.

With consul, we have multiple property sources for a configuration (application context/application itself) so the order is important.

Comment From: spencergibb

This should go in spring cloud consul

Comment From: kobynet

@spencergibb I've validated that the candidates coming from external configuration (consul in this case) are in the right order, problem is that the load is not keeping the original order but reverse it.

Comment From: spencergibb

Ok. If @philwebb says the ordering is correct, we may need to adjust in consul.

Comment From: spencergibb

I've fixed this in spring-cloud-consul https://github.com/spring-cloud/spring-cloud-consul/issues/702

Comment From: philwebb

Thanks @spencergibb