I was wondering if it is possible to specify Maven memory boundaries with a syntax similar to:
我想知道是否可以使用类似于以下语法指定Maven内存边界:
mvn -Dtest=FooTest -DXmx=512M clean test
I tried a couple of variations till now, unsuccessfully.
I am aware of MAVEN_OPTS environment variable, but I would like to avoid that.
到目前为止,我尝试了几种变化,但没有成功。我知道MAVEN_OPTS环境变量,但我想避免这种情况。
Related to the above question, it would be nice to know if there is the possibility to specify the memory behavior of the surefire plugin in a similar manner, so that it forks the jvm using the overridden memory amount (eventually overriding the <argLine>
parameter in the pom plugin configuration, if present)
与上述问题相关,很高兴知道是否有可能以类似的方式指定surefire插件的内存行为,以便它使用重写的内存量分配jvm(最终覆盖
3 个解决方案
#1
8
You can configure the surefire-plugin to use more memory. Take a look on Strange Maven out of memory error.
您可以配置surefire-plugin以使用更多内存。看看Strange Maven内存不足错误。
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.
更新:如果您想从命令行设置参数,请查看您的maven安装目录中的{{mvn.bat}}(或{{mvn}} shell脚本)。它使用命令行中指定的其他选项。
Next possibility is to set surefire-plugin and use properties specified in command-line, e.g. mvn ... -Dram=512
下一种可能性是设置surefire-plugin并使用命令行中指定的属性,例如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>
#2
37
To specify the max memory (not via MAVEN_OPTS as originally requested) you can do the following:
要指定最大内存(不是通过最初请求的MAVEN_OPTS),您可以执行以下操作:
mvn clean install -DargLine="-Xmx1524m"
#3
1
Since Maven 3.3.1 a default can also be specified in ${maven.projectBasedir}/.mvn/jvm.config
从Maven 3.3.1开始,也可以在$ {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
它在此处记录:https://maven.apache.org/docs/3.3.1/release-notes.html#JVM_and_Command_Line_Options
#1
8
You can configure the surefire-plugin to use more memory. Take a look on Strange Maven out of memory error.
您可以配置surefire-plugin以使用更多内存。看看Strange Maven内存不足错误。
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.
更新:如果您想从命令行设置参数,请查看您的maven安装目录中的{{mvn.bat}}(或{{mvn}} shell脚本)。它使用命令行中指定的其他选项。
Next possibility is to set surefire-plugin and use properties specified in command-line, e.g. mvn ... -Dram=512
下一种可能性是设置surefire-plugin并使用命令行中指定的属性,例如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>
#2
37
To specify the max memory (not via MAVEN_OPTS as originally requested) you can do the following:
要指定最大内存(不是通过最初请求的MAVEN_OPTS),您可以执行以下操作:
mvn clean install -DargLine="-Xmx1524m"
#3
1
Since Maven 3.3.1 a default can also be specified in ${maven.projectBasedir}/.mvn/jvm.config
从Maven 3.3.1开始,也可以在$ {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
它在此处记录:https://maven.apache.org/docs/3.3.1/release-notes.html#JVM_and_Command_Line_Options