maven项目编译时出现java.lang.OutOfMemoryError: GC overhead limit exceeded

在maven项目编译的时候可能出现内存异常

报错信息:

系统资源不足。
有关详细信息, 请参阅以下堆栈跟踪。
java.lang.OutOfMemoryError: GC overhead limit exceeded
	at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.readEntry(ZipFileIndex.java:669)
	at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.buildIndex(ZipFileIndex.java:580)
	at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.access$000(ZipFileIndex.java:484)
	at com.sun.tools.javac.file.ZipFileIndex.checkIndex(ZipFileIndex.java:192)
	at com.sun.tools.javac.file.ZipFileIndex.<init>(ZipFileIndex.java:137)
	at com.sun.tools.javac.file.ZipFileIndexCache.getZipFileIndex(ZipFileIndexCache.java:100)
	at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:548)
	at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:482)
	at com.sun.tools.javac.file.JavacFileManager.listContainer(JavacFileManager.java:368)
	at com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:644)
	at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2501)
	at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2145)
	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:421)
	at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:298)
	at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:459)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.complete(Enter.java:484)
	at com.sun.tools.javac.comp.Enter.main(Enter.java:469)
	at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
	at com.sun.tools.javac.main.Main.compile(Main.java:439)
	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
	at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
	at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)

系统资源不足。
有关详细信息, 请参阅以下堆栈跟踪。
java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:2219)
	at java.util.ArrayList.grow(ArrayList.java:242)
	at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:216)
	at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:208)
	at java.util.ArrayList.add(ArrayList.java:440)
	at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.readEntry(ZipFileIndex.java:676)
	at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.buildIndex(ZipFileIndex.java:580)
	at com.sun.tools.javac.file.ZipFileIndex$ZipDirectory.access$000(ZipFileIndex.java:484)
	at com.sun.tools.javac.file.ZipFileIndex.checkIndex(ZipFileIndex.java:192)
	at com.sun.tools.javac.file.ZipFileIndex.<init>(ZipFileIndex.java:137)
	at com.sun.tools.javac.file.ZipFileIndexCache.getZipFileIndex(ZipFileIndexCache.java:100)
	at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:548)
	at com.sun.tools.javac.file.JavacFileManager.openArchive(JavacFileManager.java:482)
	at com.sun.tools.javac.file.JavacFileManager.listContainer(JavacFileManager.java:368)
	at com.sun.tools.javac.file.JavacFileManager.list(JavacFileManager.java:644)
	at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2501)
	at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2145)
	at com.sun.tools.javac.code.Symbol.complete(Symbol.java:421)
	at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:298)
	at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:459)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:258)
	at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:272)
	at com.sun.tools.javac.comp.Enter.complete(Enter.java:484)
	at com.sun.tools.javac.comp.Enter.main(Enter.java:469)
	at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
	at com.sun.tools.javac.main.Main.compile(Main.java:439)
	at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
	at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
	at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)

解决办法:

配置maven执行时的JVM内存即可

注意点:

注意在系统变量中是否配置了MAVEN_OPTS系统配置,如果配置了会覆盖IDEA中的配置

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值