指定Maven内存参数而不设置MAVEN_OPTS环境变量 [英] Specifying Maven memory parameter without setting MAVEN_OPTS environment variable

查看:1182
本文介绍了指定Maven内存参数而不设置MAVEN_OPTS环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用类似于以下语法的Maven内存边界来指定:

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

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

到目前为止,我尝试了几种变体,不成功。

我知道MAVEN_OPTS环境变量,但我想避免这种情况。

I tried a couple of variations till now, unsuccessfully.
I am aware of MAVEN_OPTS environment variable, but I would like to avoid that.

与上述问题相关,知道是否有以类似的方式指定 surefire 插件的内存行为的可能性,以便它使用重写内存量来分配jvm(最终覆盖< argLine> 参数,如果存在)

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-plugin来使用更多内存。看看
奇怪的Maven内存不足错误

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

更新
如果要从命令行设置参数,请查看{{mvn .bat}}(或{{mvn}} shell脚本)。它使用命令行中指定的附加选项。

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.

下一个可能性是设置surefire-plugin并使用在命令行中指定的属性,例如。 mvn ... -Dram = 512

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

<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>

这篇关于指定Maven内存参数而不设置MAVEN_OPTS环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆