Reputation: 907
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"
Upvotes: 4
Views: 1979
Reputation: 2668
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
Upvotes: 7