修复Maven Java堆空间错误

3
长话短说,我有一个Maven项目,如果我使用以下命令,它可以正常运行:
export MAVEN_OPTS=-Xmx1024m

但是没有它,我会得到以下错误信息:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ project ---

...

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space

现在我想将配置移动到pom文件中。 我尝试了两种可能性:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <meminitial>512m</meminitial>
        <maxmem>2048m</maxmem>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

...

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <argLine>-Xmx1024m</argLine>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

这些都没有起作用。

有没有其他处理pom文件中-Xmx参数的方法?

1个回答

5

由于您无法影响当前运行的进程中的内存设置,因此必须在配置中使用<fork>true</fork>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接