spring boot external config

After some more googeling I found this Spring Boot and multiple external configuration files indicating that the following is the correct usage:

java -jar my-boot-ws.war --spring.config.location=file:///Users/TMP/resources/myFile.properties

I was under the impression that the --spring.config.location would load other properties files in the directory specified. according to the post at the link I mentioned this is not the case. based on the link if the directory is specified then that is where the application.properties is searched for. but again the documentation here http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html seems to insinuate that the spring boot app will look on the class path first and if available grab the app name to get additional properties files based on that name.

however once I specified a file name everything worked fine so I guess I was mistaken.


In command line you should use below property to mention an additional boot configuration file:

--spring.config.location="file:/path/to/application.properties"

An alternative would be:

-Dspring.config.location="file:/path/to/application.properties"

Note that characters are lower case and the word separator is a period ..

Otherwise you can use an environment variable with key you used already:

  • In a *nix system:

    export SPRING_CONFIG_NAME=file:/path/to/application.properties
    
  • In Windows OS:

    set SPRING_CONFIG_NAME=file:/path/to/application.properties