Spring External Configuration
Spring Property File is extra config can be stored in either application.properties
or application.yml
[!note]
It's recommended to stick with one format of eitherapplication.properties
orapplication.yml
.If you have both then
application.properties
takes precedence overapplication.yml
Spring will consider using the following orders:
- 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).
[!note]
If you don't like to useapplication
as the file name, we can specifyspring.config.name=myfilename
to overwrite it. For example:
java -jar myproject.jar --spring.config.name=myproject