2

A standalone(spring boot)jar can be run like this:

java -jar springboot.jar

How can I configure the configuration path as well in the command above ?

Like this below: ?

java -jar springboot.jar --configuration:/some-path-here

n.b. My configuration is external.

Thanks!

2 Answers 2

2

By default, Spring Boot will look in the working directory for external application.properties and application.yml files. For example, if you start your Spring Boot app in the same directory as the JAR:

java -jar myapp.jar 

Then this will look for application.properties (or application.yml or application-{profile}.properties etc.) in the same directory as your JAR file. This means if you set up your directory like so:

myapp/ | - myapp.jar | - application.properties 

And start the app within that directory, then it will automatically pick up the application.properties there.

If this isn't an option for you, the spring.config.location property can be specified on the command to give it additional locations to use when looking for configuration files, e.g.:

java -jar myapp.jar --spring.config.location=file:/etc/myapp/ 

For more info, read up on Spring Boot's Externalized Configuration documentation.

Sign up to request clarification or add additional context in comments.

Comments

1

As per Spring docs:

java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties

Use file instead of classpath to specify external configuration file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.