I am using the 2.7.4 version of the Spring Boot Maven plugin, and am puzzled about the behavior of arguments
set in the pom.xml
. Once there, it seems they cannot be overriden by specifying some on the command line.
According to the documentation
Arguments from the command line that should be passed to the application. Use spaces to separate multiple arguments and make sure to wrap multiple values between quotes. When specified, takes precedence over #arguments.
If I have this in my pom.xml
:
<configuration>
<arguments>
<argument>--oh_hello=there</argument>
</arguments>
</configuration>
Then I cannot override this by for example using mvn spring-boot:run -Dspring-boot.run.arguments="--hello=world"
.
The arguments seen when the Spring applications starts are stuck at what is specified in pom.xml
. I expect to be able to override this. Am I misunderstanding, or is this a bug?
Full example on GitHub.
CodePudding user response:
As counter-intuitive as it may seem, it's conventional for a Maven plugin to behave in this way, with configuration in the pom.xml
taking precedence over command-line configuration.
The reference documentation for Spring Boot's Maven plugin recommends using a project property to allow a setting to be configured on the command line. In your case, that would look something like this:
<properties>
<run.arguments>--hello=there</run.arguments>
</properties>
<configuration>
<arguments>
<argument>${run.arguments}</argument>
</arguments>
</configuration>
mvn spring-boot:run -Drun.arguments="--hello=world"