maven打包时报Java heap space

执行mvn package时,出现以下错误:
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786) at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94) at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:61) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109) at ......

解决办法:在mvn.sh中加入jvm选项,MAVEN_OPTS=-Xms512m -Xmx512m

有的时候MAVEN_OPTS=-Xms512m -Xmx512m中的值设置的过大也会报错(不能分配中够的空间),所以ms和mx的值要适当

 

你可能感兴趣的:(java,jvm,maven)