Hi! I have a multi-module maven project that uses Spring Boot.

The problem comes from the fact that the spring-boot-maven plugin does not take the active profile specified through the command line.

I have a sample project setup here https://github.com/Tamaarine/multi-module-pom

The expected behavior of when I run is that Spring boot uses the dev properties profile and not the default one. However, when I run the following command it will use the default one.

mvn spring-boot:run -Dspring.profiles.active=dev -pl core

SpringBoot Multi-module active profile through Maven Commandline not working

Interesting thing is if you provide the profile through the jvmArguments then it will work properly. Not sure if this is a bug or intended behavior? If someone could guide me that would be awesome :)

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dspring.profiles.active=dev" -pl core

Comment From: philwebb

This is expected behavior. You can read about it at https://docs.spring.io/spring-boot/docs/3.2.x/maven-plugin/reference/htmlsingle/#run, specifically:

The application is executed in a forked process and setting properties on the command-line will not affect the application

This section will also help: https://docs.spring.io/spring-boot/docs/3.2.x/maven-plugin/reference/htmlsingle/#run.examples.specify-active-profiles

For your example, you should run

$ mvn spring-boot:run -Dspring-boot.run.profiles=dev

If you have any further questions, please ask on stackoverflow.com as we prefer to keep the issue tracker for bugs and new features.