我有一个使用maven-war-plugin构建的Web应用程序
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/min</directory>
</resource>
</webResources>
</configuration>
</plugin>
当我运行maven clean package
时,构建运行良好,但是maven抱怨插件没有版本。所以我将版本添加到插件中,它变成了
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/min</directory>
</resource>
</webResources>
</configuration>
</plugin>
这次我遇到OOM错误
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.codehaus.plexus.archiver.zip.ByteArrayOutputStream.needNewBuffer (ByteArrayOutputStream.java:153)
at org.codehaus.plexus.archiver.zip.ByteArrayOutputStream.write (ByteArrayOutputStream.java:192)
at org.apache.commons.io.output.ThresholdingOutputStream.write (ThresholdingOutputStream.java:129)
at org.codehaus.plexus.archiver.zip.DeferredScatterOutputStream.writeOut (DeferredScatterOutputStream.java:44)
at org.apache.commons.compress.archivers.zip.StreamCompressor$ScatterGatherBackingStoreCompressor.writeOut (StreamCompressor.java:291)
at org.apache.commons.compress.archivers.zip.StreamCompressor.writeCounted (StreamCompressor.java:273)
我添加了<argLine>-Xmx1024m</argLine>
并更改了MAVEN_OPTS,但这些帮助都没有。
我的问题:为什么版本号很重要,如果我不包括它,那又是什么问题呢?为什么即使添加Xmx也会发生这种OOM?谢谢!
P.S。,当我不指示version
时,如果有帮助,maven使用2.2作为war插件。