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:
Try running your application with:
mvn spring-boot:run -Drun.jvmArguments="-Dspring.profiles.active=dev"
I don't know which version your are using but check this issue too
With the current version (>= 2.0.0.RELEASE), the parameter is -Dspring-boot.run.jvmArguments
Source: Sprint-boot plugin
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev"
It's also possible to do:
mvn spring-boot:run -Dspring-boot.run.profiles=dev
I also tried many ways. But in the end, what worked for me was setting them in pom.xml as mentioned in the documentation.
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.2.RELEASE</version>
<configuration>
<environmentVariables>
<ENV1>5000</ENV1>
<ENV2>Some Text</ENV2>
<ENV3/>
<ENV4></ENV4>
</environmentVariables>
</configuration>
...
</plugin>
...
</plugins>
...
</build>
...
</project>