I tried:
mvn -Dspring.profiles.active=dev spring-boot:run
but it does not affect my default configuration. I've googled a little and found:
mvn -DargLine="-Dspring.profiles.active=dev" spring-boot:run
but if fails as well.
When I run:
mvn package
and then:
java -Dspring.profiles.active=test -jar target/app-1.0.0.jar
it works as expected (the profile is changed) but fails to find file from resource dir (FileNotFound exception) which is loaded this way:
new File(getClass().getClassLoader().getResource("data.yml").getFile())
There is no problem with this file when maven is used to run the app.
Any suggestions?
With the current version (>= 2.0.0.RELEASE), the parameter is -Dspring-boot.run.jvmArguments
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev"
Source: Running your Application with Maven
To activate a speciffic profile, there is a shortcut available:
mvn spring-boot:run -Dspring-boot.run.profiles=dev
Source: Specify Active Profiles
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With