欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

解决mvn 编译java过程中Java heap space error

程序员文章站 2022-06-06 11:23:16
...

下载了protobuf2.5 但是按照readme中得步骤进行 发现 mvn test 未能通过,错误如下:

[WARNING] File encoding has not been set, using platform encoding EUC_CN, i.e. build is platform dependent!

[INFO] Compiling 60 source files to /Users/davin/Documents/open_source/protobuf-2.5.0/java/target/test-classes

 

 

ϵͳ??Դ???㡣

?й???ϸ??Ϣ??????????¶?ջ׷?١?

java.lang.OutOfMemoryError: Java heap space

at com.sun.tools.javac.util.Position$LineMapImpl.build(Position.java:139)

at com.sun.tools.javac.util.Position.makeLineMap(Position.java:63)

at com.sun.tools.javac.parser.Scanner.getLineMap(Scanner.java:1113)

at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:512)

at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:550)

at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:804)

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.api.JavacTaskImpl.call(JavacTaskImpl.java:115)

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.TestCompilerMojo.execute(TestCompilerMojo.java:152)

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)

at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)

at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)

at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)

at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)

at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)

at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)

at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)

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.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR : 

[INFO] -------------------------------------------------------------

[ERROR] An unknown compilation problem occurred

[INFO] 1 error

[INFO] -------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

 

[INFO] BUILD FAILURE

 

需要在pom.xml 中设置,meminitial 和 maxmem 2项 还有一点一定要注意一定要增加上

<fork>true</fork>

修改后如下:

<plugin>

        <artifactId>maven-compiler-plugin</artifactId>

        <version>3.1</version>

        <configuration>

        <fork>true</fork>

          <meminitial>128m</meminitial>

          <maxmem>512m</maxmem>

          <source>1.5</source>

          <target>1.5</target>

        </configuration>

  </plugin>

 

然后在进行mvn test 

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1:14.484s

[INFO] Finished at: Tue May 13 11:30:37 CST 2014

 

[INFO] Final Memory: 8M/81M

 

附件是修改后的整个pom.xml 备参考。