如何增加aspectj-maven-plugin的内存限制

时间:2013-12-24 16:38:56

标签: java maven aspectj aspectj-maven-plugin

我正在尝试使用Maven构建项目,但是我收到了这个错误:

[INFO] --- aspectj-maven-plugin:1.4:compile (default) @ core ---
[ERROR] ABORT
[ERROR] AspectJ 1.6.1 ran out of memory during compilation:

Please increase the memory available to ajc by editing the ajc script 
found in your AspectJ installation directory. The -Xmx parameter value
should be increased from 64M (default) to 128M or even 256M.

我尝试在pom.xml中配置aspectj-maven-plugin,但它没有任何效果:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.4</version>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>1.6.1</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>1.6.1</version>
                </dependency>
            </dependencies>
            <configuration>
                <argLine>-Xmx1024m</argLine>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>UTF-8</encoding>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我的本​​地副本工作正常,此错误仅在部署中发生。如何解决?

2 个答案:

答案 0 :(得分:2)

export MAVEN_OPTS="-Xmx2048m -XX:MaxPermSize=512m"

进入构建脚本解决了问题。 (我试过用1024m)

答案 1 :(得分:0)

我似乎无法在插件手册中找到任何内存使用选项。也许你应该按照它的建议去做,并手动更改本地安装目录中的ajc脚本(虽然我必须承认这似乎是一个糟糕的解决方案)