Specifying Maven memory parameter without setting MAVEN_OPTS environment variable

后端 未结 3 1272
长情又很酷
长情又很酷 2020-12-09 03:25

I was wondering if it is possible to specify Maven memory boundaries with a syntax similar to:

mvn -Dtest=FooTest -DXmx=512M clean test

I t

相关标签:
3条回答
  • 2020-12-09 04:01

    You can configure the surefire-plugin to use more memory. Take a look on Strange Maven out of memory error.

    Update: If you would like to set the parameter from command-line take a look on {{mvn.bat}} (or {{mvn}} shell script) in your maven installation directory. It uses with additional options specified in command line.

    Next possibility is to set surefire-plugin and use properties specified in command-line, e.g. mvn ... -Dram=512

    and

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.5</version>
        <configuration>
            <forkMode>once</forkMode>
            <argLine>-Xms${ram}m -Xmx${ram}m</argLine>
        </configuration>
    </plugin>
    
    0 讨论(0)
  • 2020-12-09 04:03

    Since Maven 3.3.1 a default can also be specified in ${maven.projectBasedir}/.mvn/jvm.config

    It is documented here: https://maven.apache.org/docs/3.3.1/release-notes.html#JVM_and_Command_Line_Options

    0 讨论(0)
  • 2020-12-09 04:12

    To specify the max memory (not via MAVEN_OPTS as originally requested) you can do the following:

    mvn clean install -DargLine="-Xmx1524m"
    
    0 讨论(0)
提交回复
热议问题