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.(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.(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项目编译时出现java.lang.OutOfMemoryError: GC overhead limit exceeded_第1张图片

注意点:

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

你可能感兴趣的:(配置)