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.propertiesorapplication.yml.If you have both then
application.propertiestakes precedence overapplication.yml
Spring will consider using the following orders:
- Application properties packaged inside your jar (
application.propertiesand YAML variants). - Profile-specific application properties packaged inside your jar (
application-{profile}.propertiesand YAML variants). - Application properties outside of your packaged jar (
application.propertiesand YAML variants). - Profile-specific application properties outside of your packaged jar (
application-{profile}.propertiesand YAML variants).
[!note]
If you don't like to useapplicationas the file name, we can specifyspring.config.name=myfilenameto overwrite it. For example:
java -jar myproject.jar --spring.config.name=myproject