Maven And Spring Boot: Get Maven Plugin Command Line Options

Spring Boot 2.0.0

One of the issues I hit regularly is remembering the various command line arguments that can be sent to the Maven Spring Boot plugin. Specifically, arguments to be passed to the underlying application when I'm doing:

 $ mvn spring-boot:run

To find the list of options, use the following command line:

  $ mvn help:describe -Dcmd=spring-boot:run -Ddetail

Which outputs the following:

Mojo: 'spring-boot:run'
spring-boot:run
  Description: Run an executable archive application.
  Implementation: org.springframework.boot.maven.RunMojo
  Language: java
  Bound to phase: validate
  Before this goal executes, it will call:
    Phase: 'test-compile'

  Available parameters:

    addResources (Default: false)
      User property: spring-boot.run.addResources
      Add maven resources to the classpath directly, this allows live in-place
      editing of resources. Duplicate resources are removed from target/classes
      to prevent them to appear twice if ClassLoader.getResources() is called.
      Please consider adding spring-boot-devtools to your project instead as it
      provides this feature and many more.

    agent
      User property: spring-boot.run.agent
      Path to agent jar. NOTE: the use of agents means that processes will be
      started by forking a new JVM.

    arguments
      User property: spring-boot.run.arguments
      Arguments that should be passed to the application. On command line use
      commas to separate multiple arguments.

    classesDirectory (Default: ${project.build.outputDirectory})
      Required: true
      Directory containing the classes and resource files that should be
      packaged into the archive.

    environmentVariables
      List of Environment variables that should be associated with the forked
      process used to run the application. NOTE: the use of Environment
      variables means that processes will be started by forking a new JVM.

    excludeGroupIds
      User property: spring-boot.excludeGroupIds
      Comma separated list of groupId names to exclude (exact match).

    excludes
      User property: spring-boot.excludes
      Collection of artifact definitions to exclude. The Exclude element
      defines a groupId and artifactId mandatory properties and an optional
      classifier property.

    folders
      User property: spring-boot.run.folders
      Additional folders besides the classes directory that should be added to
      the classpath.

    fork
      User property: spring-boot.run.fork
      Flag to indicate if the run processes should be forked. fork is
      automatically enabled if an agent, jvmArguments or working directory are
      specified, or if devtools is present.

    includes
      User property: spring-boot.includes
      Collection of artifact definitions to include. The Include element
      defines a groupId and artifactId mandatory properties and an optional
      classifier property.

    jvmArguments
      User property: spring-boot.run.jvmArguments
      JVM arguments that should be associated with the forked process used to
      run the application. On command line, make sure to wrap multiple values
      between quotes. NOTE: the use of JVM arguments means that processes will
      be started by forking a new JVM.

    mainClass
      User property: spring-boot.run.main-class
      The name of the main class. If not specified the first compiled class
      found that contains a 'main' method will be used.

    noverify
      User property: spring-boot.run.noverify
      Flag to say that the agent requires -noverify.

    profiles
      User property: spring-boot.run.profiles
      The spring profiles to activate. Convenience shortcut of specifying the
      'spring.profiles.active' argument. On command line use commas to separate
      multiple profiles.

    skip (Default: false)
      User property: spring-boot.run.skip
      Skip the execution.

    systemPropertyVariables
      List of JVM system properties to pass to the process. NOTE: the use of
      system properties means that processes will be started by forking a new
      JVM.

    useTestClasspath (Default: false)
      User property: spring-boot.run.useTestClasspath
      Flag to include the test classpath when running.

    workingDirectory
      User property: spring-boot.run.workingDirectory
      Current working directory to use for the application. If not specified,
      basedir will be used. NOTE: the use of working directory means that
      processes will be started by forking a new JVM.


And then, specifically, to provide arguments to the underlying application, you would use:

  $ mvn spring-boot:run -Dspring-boot.run.arguments=[the list of comma separated options]


Comments