【问题标题】:How to increase aspectj-maven-plugin's memory limit如何增加aspectj-maven-plugin的内存限制
【发布时间】:2013-12-24 16:38:56
【问题描述】:

我正在尝试使用 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>

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

【问题讨论】:

  • 我没有看到 aspectj maven 插件的 argLine 设置。猜猜你必须设置 MAVEN_OPTS 环境变量来解决这个问题。
  • @AndrewLogvinov 在运行重建脚本之前尝试执行export MAVEN_OPTS="-Xmx1024m",但没有帮助

标签: java maven aspectj aspectj-maven-plugin


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 在哪里可以找到这个本地安装目录?我不记得安装 aspectJ,我只能在我的 .m2 存储库中找到它作为 jars
    猜你喜欢
    • 1970-01-01
    • 2013-01-08
    • 1970-01-01
    • 2012-03-08
    • 1970-01-01
    • 2013-07-28
    • 2022-01-03
    • 2023-03-22
    相关资源
    最近更新 更多