一尘不染

我的工件似乎很大,可以由maven部署。我能做什么?

jenkins

我的Maven 3.0.3版本在Jenkins中设置了-Xmx1G-XX:MaxPermSize=500M。但是,当我进行部署时,我总是

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 org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:492)
    at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:457)
    at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:411)
    at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:392)
    at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:365)
    at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:825)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:465)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:278)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:215)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:480)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:188)
    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:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    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)

部署的工件283M很大。如何正确部署它?


阅读 266

收藏
2020-07-25

共1个答案

一尘不染

此问题是由此bug引起的。如链接中所建议,只需使用webdav进行部署。

考虑执行以下操作:

<project>
  [...]
  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-webdav</artifactId>
        <version>1.0</version>
      </extension>
    </extensions>  
    </plugin>
  </build>
  ...
  <distributionManagement>
    <site>
        <id>sample-project.website</id>
        <url>dav:https://dav.sample.com/sites/sample-project</url>
    </site>
  </distributionManagement>
  ...
</project>

我以前有过这个问题。我相信只有在大小大于等于256 MB的工件时才会发生这种情况。

切换到webdav部署方法后,您还可以减少内存设置。(如果您只是由于部署过程中的内存问题而专门修改了它们)。

2020-07-25