maven mvn运行出错

今天在buildGlassFish源码时出现错误,后来在mvn后加上 -X,打印出详细信息出如下:

[INFO] Scanning for projects...
[ERROR] Java heap space -> [Help 1]
java.lang.OutOfMemoryError: Java heap space
at org.apache.maven.model.Dependency.clone(Dependency.java:204)
at org.apache.maven.model.DependencyManagement.clone(DependencyManagemen
t.java:67)
at org.apache.maven.model.ModelBase.clone(ModelBase.java:190)
at org.apache.maven.model.Model.clone(Model.java:260)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultMode
lBuilder.java:279)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultMode
lBuilder.java:232)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBu
ilder.java:410)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBu
ilder.java:379)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBu
ilder.java:495)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryErr
or

转到相应的wiki页查看,原因如下:

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

Fixing this error is usually just a matter of assigning more memory to the JVM. If you run from the command line, this can be done by means of the environment variable MAVEN_OPTS. This variable can be used to specify options for the JVM itself. In case of "Java heap space", the option of interest is -Xmx, in case of "PermGen space" it's usually -XX:MaxPermSize. For example, on Windows you would use

set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m

设置后再次运行mvn ,可能正常执行了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值