问题:我运行mvn clean install -DskipTest
并获取
[ERROR] The system is out of resources.
[ERROR] Consult the following stack trace for details.
[ERROR] java.lang.OutOfMemoryError: Java heap space
更多信息:
操作系统: OS X(16 GB RAM)
Java配置:位于~/Libraries/Preferences/IntelliJIdea13/idea.vmoptins
和Applications/IntelliJ\ Idea\ 13.app/bin/idea.vmoptions
-Xms256m -Xmx2048m -XX:MaxPermSize参数=1024米 -XX:ReservedCodeCacheSize =256米 -XX:+ UseCompressedOops
MAVEN_OPTS: export MAVEN_OPTS="-Xmx2048M -XX:PermSize=92M -XX:MaxPermSize=384M"
位于~/.bash_profile
Intellij Idea maven opts: -xms256m -xmx2048 -XX:MaxPermSize=1024M
。我在Default Settings
- >中设置了它们MAven
- > Runner
- > VM Options
问题: 如何解决?
堆栈跟踪:
[ERROR] The system is out of resources.
[ERROR] Consult the following stack trace for details.
[ERROR] java.lang.OutOfMemoryError: Java heap space
[ERROR] at com.sun.tools.javac.util.Position$LineMapImpl.build(Position.java:139)
[ERROR] at com.sun.tools.javac.util.Position.makeLineMap(Position.java:63)
[ERROR] at com.sun.tools.javac.parser.Scanner.getLineMap(Scanner.java:1113)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:512)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:550)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:804)
[ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:353)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:279)
[ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:270)
[ERROR] at com.sun.tools.javac.Main.compile(Main.java:87)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:554)
[ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:161)
[ERROR] at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:605)
[ERROR] at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project com.conductor.thrift.client: Compilation failure
Failure executing javac, but could not parse the error:
答案 0 :(得分:9)
基于上面的注释,Java编译器插件内存不足,为了解决这个问题,您需要为Java编译器插件提供更多内存,并在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>