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 either application.properties or application.yml.

If you have both then application.properties takes precedence over application.yml

Spring will consider using the following orders:

  1. Application properties packaged inside your jar (application.properties and YAML variants).
  2. Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants).
  3. Application properties outside of your packaged jar (application.properties and YAML variants).
  4. Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants).

[!note]
If you don't like to use application as the file name, we can specify spring.config.name=myfilename to overwrite it. For example:

java -jar myproject.jar --spring.config.name=myproject