在Intellij-idea中用maven编译项目时出现了下面的异常信息:
系统资源不足。
有关详细信息,请参阅以下堆栈追踪。
java.lang.OutOfMemoryError: Java heap space
at com.sun.tools.javac.zip.ZipFileIndex$ZipDirectory.findCENRecord(ZipFileIndex.java:698)
at com.sun.tools.javac.zip.ZipFileIndex$ZipDirectory.<init>(ZipFileIndex.java:665)
at com.sun.tools.javac.zip.ZipFileIndex.checkIndex(ZipFileIndex.java:260)
at com.sun.tools.javac.zip.ZipFileIndex.<init>(ZipFileIndex.java:209)
at com.sun.tools.javac.zip.ZipFileIndex.getZipFileIndex(ZipFileIndex.java:115)
at com.sun.tools.javac.util.DefaultFileManager.openArchive(DefaultFileManager.java:636)
at com.sun.tools.javac.util.DefaultFileManager.listDirectory(DefaultFileManager.java:325)
at com.sun.tools.javac.util.DefaultFileManager.list(DefaultFileManager.java:872)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2130)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1781)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.too
ls.javac.comp.Enter.visitTopLevel(Enter.java:272)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:446)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:236)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:250)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:444)
at com.sun.tools.javac.comp.Enter.main(Enter.java:429)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:819)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Met
hod.invoke(Method.java:597)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:554)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:161)
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:605)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
[INFO] 1error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
系统资源不足。
有关详细信息,请参阅以下堆栈追踪。
java.lang.OutOfMemoryError: Java heap space
at com.sun.tools.javac.zip.ZipFileIndex$ZipDirectory.findCENRecord(ZipF
ileIndex.java:698)
at com.sun.tools.javac.zip.ZipFileIndex$ZipDirectory.<init>(ZipFileIndex.java:665)
at com.sun.tools.javac.zip.ZipFileIndex.checkIndex(ZipFileIndex.java:260)
at com.sun.tools.javac.zip.ZipFileIndex.<init>(ZipFileIndex.java:209)
at com.sun.tools.javac.zip.ZipFileIndex.getZipFileIndex(ZipFileIndex.java:115)
at com.sun.tools.javac.util.DefaultFileManager.openArchive(DefaultFileManager.java:636)
at com.sun.tools.javac.util.DefaultFileManager.listDirectory(DefaultFileManager.java:325)
at com.sun.tools.javac.util.DefaultFileManager.list(DefaultFileManager.java:872)
at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2130)
at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1781)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.comp.Enter.visitTopLevel(Enter.java:272)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:446)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:236)
at com.sun.tools.javac.comp.Enter.classEnter(Enter.java:250)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:444)
at com.sun.tools.javac.comp.Enter.main(Enter.java:429)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:819)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:554)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCo
mpiler.java:161)
四个字就是:内存溢出了,出现这个问题,首先我们第一印象是maven内存不够用了,于是修改maven的bat文件,修改它的内存,但是修改后没有效果。然后我们会继续修改intellij-idea的内存,但是都没有效果。
为什么呢?因为我们没有找对点,我们应该修改pom.xml文件中编译插件的内存设置,如下:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<meminitial>512m</meminitial>
<maxmem>1048m</maxmem>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
你需要根据你的实际情况修改maven-compiler-plugin的内存配置。