-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Closed
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: documentationA documentation updateA documentation update
Description
In 4.2. Externalized Configuration (Spring Boot 2.4.2) it states that
Config data files are considered in the following order:
- Application properties packaged inside your jar (application.properties and YAML variants).
- Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
- Application properties outside of your packaged jar (application.properties and YAML variants).
- Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).
However, what is unclear is which config values wins if you have both application.yml
and application.properties
on the same level. We'd like to use Variant 1 (see below), which seems to work, but relies on undocumented behavior that could easily change, so it would be great if the precedence handling could be added to the docs and checked with tests, if that is not already the case.
Context:
In SB <2.4 we used:
src/main/application.yml
to store profilessrc/main/application-default.properties
to setspring.profiles.include=stage-workstation
to activate a profile if nothing was activated via ENV/systemproperty. (We used the properties file as this key is invalid in yml, but using this file makes it also easy to override for test)src/test/application-default.properties
to setspring.profiles.include=stage-workstation, test
to activate the test profilesrc/main/application-test.yml
with profile in the name to avoid overriding theapplication.yml
For SB 2.4.x
We are evaluating two solutions
Variant 1
src/main/application.yml
to store profiles and usespring.profiles.group.default=stage-workstation
src/test/application.properties
to setspring.profiles.group.default=stage-workstation,test
to activate the test profile and use properties instead of yml to avoid overriding theapplication.yml
src/main/application-test.yml
with profile in the name to avoid overriding theapplication.yml
Variant 2
src/main/application.yml
to store profiles and usespring.profiles.group.default=stage-workstation
src/test/application.yml
that usesspring.config.import=file:${user.dir}/src/main/resources/application.yml
and overrides thespring.profiles.group.default=stage-workstation,test
(IMHO it is rather brittle to rely on${user.dir}
to be set to the correct location)
Metadata
Metadata
Assignees
Labels
status: supersededAn issue that has been superseded by anotherAn issue that has been superseded by anothertype: documentationA documentation updateA documentation update