-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Clarifying change in config file ordering particularly with respect to spring.config.location and profile-specific files #25058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you seen the section in the release notes and the migration guide to which it links? If not, please take a look and let us know if it helps. |
Thanks for that - not immediately obvious, although I have sorted it. So the guide says:
This is the key. I have been using profiles of base,dev with a spring.config.location=file:./,classpath:/config/. Of course this meant my external file did override the internal due to profile activation order. In 2.4 the location order now takes precedence and it is then fairly obvious that I specify the local directory first. So simple fix to reverse the ordering on spring.config.location. No bug - although maybe worth an extra note in the migration guide because the behaviour of spring.config.location in combination with the profiles is not mentioned. Thanks for your help! |
That sounds like a good idea to me. Thanks for the suggestion. The section you've referenced is specifically about multi-document YAML files which you weren't using so there's definitely some room for improvement. I've re-opened this issue as a reminder to update the guide. |
We should probably reword "As of Spring Boot 2.4, external file always override packaged files (profile-specific or not)". The "always" only applies when using the default locations. If they're overridden and their ordering is changed, the "always" no longer holds true. |
I have a gradle build using multiple profiles to provide configuration overrides for different environments (live + dev).
app-base.properties is located inside the war
app-dev.properties is located outside the war in the top directory of the build so gradle bootRun will run with app-dev.properties overriding app-base.properties.
logging.file.name in app-base.properties is set to the live deployment logging directory.
logging.file..name in app-dev.properties is set to ./app.log
This setup has worked for the last 12 months, the gradle configuration that works is:
An upgrade to 2.4.2 with the following plugins, breaks the execution.
Here the logging.file.name set in app-dev.properties is ignored. The app-base.properties is used instead. To resolve I have had to downgrade back to 2.3.8.RELEASE.
The text was updated successfully, but these errors were encountered: