Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot: path to application.properties

Let's say I want to load the application.properties from /tmp/application.properties. How do I do it when I usually execute the app with

mvn spring-boot:run

I read all docs and stackoverflow posts but I cannot get it working. Usually I find:

java -jar -Dspring.config.location=<path-to-file> myBootProject.jar

But this does not seem to work when executing via mvn-spring-boot:run. I also tried without success:

mvn spring-boot:run -Drun.jvmArguments="-Dspring.config.location=/tmp/application.properties"
like image 203
NoobieNoob Avatar asked Oct 19 '25 09:10

NoobieNoob


1 Answers

The spring-boot:run goal has an optional parameter that is used exactly for that purpose: spring-boot.run.arguments.

In your case, the property you want to configure is --spring.config.location=<path-to-file>. So you can use the following command:

mvn spring-boot:run -Dspring-boot.run.arguments=--spring.config.location=<path-to-file>

Source: https://docs.spring.io/spring-boot/docs/current/maven-plugin/run-mojo.html#arguments

like image 157
Gustavo Passini Avatar answered Oct 22 '25 01:10

Gustavo Passini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!