zoukankan      html  css  js  c++  java
  • maven 打包 OutOfMemoryError

    maven 打包 OutOfMemoryError

    [ERROR] Java heap space -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError
    

    查看官方文档,内存溢出可能有以下几种情况:

    1. You are building a very big multi-module project, each module requires a certain amount of memory so with increasing number of modules the amount of required memory increases as well until the JVM finally runs out of "Java heap space".
    2. You are using some plugins that perform memory-intensive operations like analyzing the class files of all project dependencies.
    3. You are using the Maven Compiler Plugin with the option fork=false (default) and your project has a lot of source files to compile. When using the Java compiler in embedded mode, each compiled class will consume heap memory and depending on the JDK being used this memory is not subject to gargabe collection, i.e. the memory allocated for the compiled classes will not be freed. The resultant error message typically says "PermGen space".

    我的工程 pom.xml 中配制有

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <!-- <filtering>true</filtering> -->
            <includes>
                <include>**/*.*</include>
            </includes>
        </resource>
    </resources>
    

    filtering 配制为 true 后,会扫描资源路径下的文件,将文件中的变量解析出来,恰好 resources 文件下有一个 27M 的文件,结果就内存溢出了,解决的办法很简单,将 filtering 改为 false 就好。

    官网上还给出了另一种解决方案:

    # Windows 
    set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m
    # Unix
    export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
    

    每天用心记录一点点。内容也许不重要,但习惯很重要!

  • 相关阅读:
    大约PCA算法学习总结
    内部硬盘的硬件结构和工作原理进行了详细解释
    DWZ使用注意事项
    cocos2d-x 在XML分析和数据存储
    HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth完全详细的说明
    hdu 1114 Piggy-Bank
    getResources()方法
    人机博弈-吃跳棋游戏(三)代移动
    Oracle 11g client安装和配置。
    的微信公众号开发 图灵机器人接口允许调用自己的微通道成为一个智能机器人
  • 原文地址:https://www.cnblogs.com/binarylei/p/8792905.html
Copyright © 2011-2022 走看看