Since Spring Boot v2+
I have verified with Spring Boot v2.3.5.RELEASE
With Spring Boot Maven Plugin
You can provide commandline argument like this:
mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=dev"
You can provide JVM argument like this:
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev"
java -jar
java -Dspring.profiles.active=dev -jar app.jar
(Note order)
or
java -jar app.jar --spring.profiles.active=dev
(Note order)