ePrivacy and GPDR Cookie Consent by Cookie Consent Passing Arguments to spring-boot:run - Develop In Java
Develop In Java
All things Java and development

Passing Arguments to spring-boot:run


When developing applications using SpringBoot and Maven, there are several ways to run the applications. You can run via an IDE, from a packaged .jar file, or from, Maven using the spring-boot-maven-plugin

Configuring the plugin

To use the spring-boot-maven-plugin, configuration is required within the project's pom.xml file. The plugin needs to be defined as shown below.


Running the application

After defining the spring-boot-maven-plugin, the application can be started from the command line using maven:

$ mvn spring-boot:run

Configuring parameters

Normally when running a Java process, you can specify command line parameters using the -D... option, or via the --spring... option. These techniques however do not work when using the plugin. To specify the arguments, we need to use the -Dspring-boot.run.arguments option. This allows us to then separate a list of space separated parameters. For example:

$ mvn spring-boot:run \
 -Dspring-boot.run.arguments= \
 "--spring.datasource.url=jdbc:.... --spring.datasource.username=..."


In this article, we've seen how to run a Spring Boot application using Maven and the Spring Boot Maven Plugin. The plugin can however do much more than simply running your application. Check of the official docs for further details.


Photo by Kelly Sikkema on Unsplash