从Eclipse向Nexus部署工件时出错

时间:2013-03-19 07:42:03

标签: eclipse maven nexus artifacts

在我们的服务器上安装了Nexus,并设置了快照和发布存储库。

修改了我的子模块maven项目中顶层项目的pom.xml文件,添加了这些行:

  <distributionManagement>
    <snapshotRepository>
        <id>Snapshots</id>
        <url>http://maven:8081/nexus/content/repositories/Snapshots</url>
    </snapshotRepository>
    <repository>
        <id>Releases</id>
        <url>http://maven:8081/nexus/content/repositories/Releases</url>
    </repository>
  </distributionManagement>

我已将settings.xml添加到.m2目录,其中包含以下内容:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!--
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  -->
  <servers>

    <server>
      <id>Snapshots</id>
      <username>user</username>
      <password>pass</password>

      <privateKey>${user.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase>

      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>

    </server>

  </servers>
  <!--
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
  -->
</settings>

当我在我的顶级项目中使用eclipse的部署目标运行maven时,maven开始构建并同步(上传)到快照存储库。顶级项目上传,但在构建第一个子模块并开始同步后,我不断上传:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project <my sub module project>: Failed to deploy artifacts: Could not transfer artifact <group id>:<artifact id>:xml:0.0.1-20130318.160312-21 from/to Snapshots (http://maven:8081/nexus/content/repositories/Snapshots): Remotely Closed [id: 0x017ae341, /192.168.10.237:58758 :> maven/192.168.10.36:8081]

奇怪的是,如果我从Nexus界面浏览我的repo,子项目就在那里有xml和jar等等。问题是因为错误maven停止并且我的所有其他子项目都没有部署。

任何人都知道如何解决这个问题?

更新 如果我使用distributionManagement-tag创建单个maven项目,我可以毫无问题地部署到Nexus。但是当我有多个maven项目时,我得到了错误。我试图将distributionManagement添加到child-pom,但是我得到了同样的错误。

如何将poms部署到有关distributionManagement标记的存储库?

1 个答案:

答案 0 :(得分:2)

经过几个小时的调查后,我发现了我的问题。 我的父pom.xml中有一个部分,它将一个features.xml添加到父仓库。

<build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <version>${maven-resources-plugin.version}</version>
              <executions>
                 <execution>
                    <id>filter</id>
                    <phase>generate-resources</phase>
                    <goals>
                      <goal>resources</goal>
                    </goals>
                 </execution>
              </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${build-helper-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>target/classes/features.xml</file>
                                    <type>xml</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
         </plugins>
   </build>

这导致了“远程关闭”问题。