Matteo_B
Matteo_B

Reputation: 51

Choose application.properties file via command line

I'm developing a command line Spring Boot Application, and I need Spring to load his configurations (DB URLs, users, etc), not necessarily from the default application.properties file, but on a .properties file specified in the String[] args parameter. I may use some hints about how this could be implemented. Thanks for your time.

Upvotes: 0

Views: 2276

Answers (1)

Rob Scully
Rob Scully

Reputation: 790

This can be done via the spring.config.location property.

In your command line you would add the

-Dspring.config.location=C:/application.properties (or whatever the path may be). 

This will then replace any properties file you have in your spring boot application and you can alter it at will at run time.

Upvotes: 1

Related Questions