2013-03-19 50 views
1

在我們的服務器上安裝了Nexus並設置了快照和發行版存儲庫。將工件從Eclipse部署到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中運行與部署目標行家,行家開始建立和同步(上傳)的快照回購。頂部項目被上傳,但第一個子模塊建成後,開始同步我不斷收到:

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界面中的子項目有使用XML的和jar的等等。但問題是,因爲錯誤maven停止,我所有的其他子項目都沒有部署。

任何人都知道如何解決這個問題?

UPDATE: 如果我創建一個Maven項目與distributionManagement標籤我可以毫無問題的Nexus部署。但是當有多個maven項目時,我得到錯誤。我試圖將distributionManagement添加到child-pom中,但我得到了同樣的錯誤。

poms應該如何看起來像部署到存儲庫有關distributionManagement標記?

+1

「遠程關閉」...看看Nexus日誌可能會有所幫助。或者在通往Nexus存儲庫的途中使用代理。 – ben75 2013-03-19 09:50:09

+0

閱讀本文http://maven.apache.org/guides/mini/guide-proxies.html – ben75 2013-03-19 09:56:01

+0

當你說代理是否意味着一個maven代理或在tcp/ip級別的代理?我不認爲這可能是一個代理問題,我的工件最終在Maven服務器上。如果我在settings.xml中輸入錯誤的證書,我會收到授權錯誤。 – Marcus 2013-03-19 10:45:47

回答

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> 

這一個引起了「遠程關閉」問題。