System properties can be specified using the systemPropertyVariables
attribute. The following sets property1
to test
and property2
to 42:
<project> ... <build> <properties> <my.value>42</my.value> </properties> ... <plugins> ... <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <systemPropertyVariables> <property1>test</property1> <property2>${my.value}</property2> </systemPropertyVariables> </configuration> ... </plugin> ... </plugins> ... </build> ... </project>
If the value is empty or not defined (i.e. <my-property/
>), the system property is set with an empty String as the value. Maven trims values specified in the pom so it is not possible to specify a System property which needs to start or end with a space via this mechanism: consider using jvmArguments
instead.
Any String typed Maven variable can be passed as system properties. Any attempt to pass any other Maven variable type (e.g. a List
or a URL
variable) will cause the variable expression to be passed literally (unevaluated).
The jvmArguments
parameter takes precedence over system properties defined with the mechanism above. In the following example, the value for property1
is overridden
:
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dproperty1=overridden"