As stated in spring-boot-reference:
On your application classpath (e.g. inside your jar) you can have an
application.properties that provides a sensible default property value
for name. When running in a new environment, an application.properties
can be provided outside of your jar that overrides the name
java -jar target/myproject-0.0.1-SNAPSHOT.jar
java -Dspring.config.location=/target/application.properties -jar target/myproject-0.0.1-SNAPSHOT.jar
java -jar myproject-0.0.1-SNAPSHOT.jar
Just as you say in your edit, it doesn't work because we you trying to launch the jar from another folder.
The reason it doesn't work, is that spring boot looks for files/folder relative your current folder.
(1) copy application.properties one level below target (in
(2) Or execute like this (without forward slash for the location path):
$ java -Dspring.config.location=target/application.properties -jar target/myproject-0.0.1-SNAPSHOT.jar