Keep in mind: the method of passing arguments depends on the main version of spring-boot .
TL; DR
For Spring Boot 1:
mvn spring-boot:run -Drun.arguments="argOne,argTwo"
For Spring Boot 2:
mvn spring-boot:run -Dspring-boot.run.arguments="argOne,argTwo"
1) the version of spring-boot-maven-plugin and the used version of Spring Boot should be aligned.
According to the main version of Spring Boot used ( 1 or 2 ), it is really necessary to use spring-boot-maven-plugin in version 1 or 2 .
If your pom.xml inherits from spring-boot-starter-parent :
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>ONE_OR_TWO_VERSION</version> </parent>
In your pom, the version of the plugin used should not even be specified, since this plugin dependency is inherited:
<plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> ... </configuration> </plugin> </plugins>
If your pom.xml not inherited from spring-boot-starter-parent , be sure to align the version of spring-boot-maven-plugin with the exact version of spring boot you want to use.
2) Passing arguments on the command line using spring-boot-maven-plugin: 1.XX
For one argument:
mvn spring-boot:run -Drun.arguments="argOne"
for several:
mvn spring-boot:run -Drun.arguments="argOne,argTwo"
The maven plugin page documents this:
Name Type Since Description arguments | String[] | 1.0 | Arguments that should be passed to the application. On command line use commas to separate multiple arguments. User property is: run.arguments.
3) Passing arguments on the command line using spring-boot-maven-plugin: 2.XX
For one argument:
mvn spring-boot:run -Dspring-boot.run.arguments="argOne"
for several:
mvn spring-boot:run -Dspring-boot.run.arguments="argOne,argTwo"
I did not find the plugin documentation for version 2.XX that references this.
But the org.springframework.boot.maven.AbstractRunMojo class from spring-boot-maven-plugin:2.0.0.M3 refers to this user property:
public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo ... @Parameter(property="spring-boot.run.arguments") private String[] arguments; ... protected RunArguments resolveApplicationArguments(){ RunArguments runArguments = new RunArguments(this.arguments); addActiveProfileArgument(runArguments); return runArguments; } ... }
4) Hint: when passing more than one argument, spaces between commas are taken into account.
mvn spring-boot:run -Dspring-boot.run.arguments="argOne,argTwo"
will be interpreted as ["argOne", "argTwo"]
But this:
mvn spring-boot:run -Dspring-boot.run.arguments="argOne, argTwo"
will be interpreted as ["argOne", " argTwo"]