Hello,

I was trying to upgrade our applications from 2.4.6 to 2.5.1 and noticed a change of behavior in property loading order. And after further testing, this change of behavior is happening in both 2.4.7 and 2.5.1, so it has to be a quite recent commit.

Personally, I am not sure about the correct behavior anymore (even after reading your documentation :) ... What is bothering us is this is breaking many applications on our side and it would be nice to at least know the future direction of designing the configuration hierarchy, so that we don't have so much pain each time we upgrade... Hope you could understand our concern.

I have provided an example here: https://github.com/chengchen/spring-boot-properties-loading-debug

After building and starting the app:

$ mvn clean install
$ cd app && mvn spring-boot:run

We execute this:

$ curl localhost:8080/bar

If using 2.4.6, the output is app-default. If using 2.5.1 or 2.4.7, the output is common.

The reason we do like this is to reuse some common modules between several applications, but still allow to override some module default values. Of course, we could override in more specific profiles like application-prod.yml but we try to avoid repeating in other environment like application-staging.yml when this value is somehow application default.

Many thanks for your help!

Comment From: philwebb

I suspect this is a duplicate of #26960. I'll check your sample once I've committed a fix.

Comment From: philwebb

I was wrong, this is not a duplicate of #26960, you're actually hitting the fix for #26593. I'm afraid that one is a legitimate bug in my opinion and we should be loading all regular files before all profile-specific file (regardless of if they are under /config or not).

We have an open issue (#24688) to look at improving your scenario since it seems to come up a lot. For now, I would recommend that you use an EnvironmentPostProcessor in your common lib to add a property source containing the common properties. You can register it in META-INF/spring.factories and it will be picked up automatically. Take a look at #27000 which has some sample code that shows the basic approach.

Comment From: chengchen

Hi @philwebb

Thank you for your investigation! I did come across that ticket yesterday but as I said I was not sure about the correct behavior :) So, you are basically indicating that the current 2.5.1 should hold the expected/correct behavior. I will try to adapt our config to it then...

I will probably not use a EnvironmentPostProcessor which is too much coupling to Spring stuff... and adds unnecessary complications. Thanks anyway!