2014-02-18 75 views
1

我剛剛在Windows Tomcat上安裝了Nexus 2.7.1並啓動並運行。我正在嘗試使用「maven deploy」命令將SNAPSHOT jar部署到Nexus快照倉庫,但遇到以下錯誤。使用Maven版本3.0.5。請指導。無法將快照工件部署到連接

[錯誤]未能執行目標org.apache.maven.plugins:行家 - 部署 - 插件:2.7:在項目部署(默認部署)釋放插件-RND:未能部署文物:無法轉移artifacts com.s tudy:release-plugin-rnd:jar:1.3-20140218.193240-1 from/to snapshots(http://my-nexus-server.com:9090/nexus/content/repositories/snapshots):無法傳輸文件:http://my-nexus-server.com:9090/nexus/content/repos itories/snapshots/com/study/release-plugin-rnd/1.3 -SNAPSHOT /釋放-插件-RND-1.3-20140218.193240-1.jar。 * 返回碼爲:401,ReasonPhrase:未經授權。 - > [Help 1] *

我的settings.xml和pom.xml如下所述。

的settings.xml

<settings> 
    <mirrors> 
     <mirror> 
      <id>Nexus</id> 
      <name>Nexus Public Mirror</name> 
      <url>http://localhost:9090/nexus/content/groups/public</url> 
      <mirrorOf>central</mirrorOf> 
     </mirror> 
    </mirrors> 
    <servers> 
     <server> 
      <id>nexus-server</id> 
      <username>admin</username> 
      <password>admin123</password> 
     </server> 
    </servers> 
</settings> 

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.study</groupId> 
    <artifactId>release-plugin-rnd</artifactId> 
    <version>1.3-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>release-plugin-rnd</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <scm> 
     <connection>scm:svn:https://my-svn-server/svn/maven-rnd/release-plugin-rnd/trunk</connection> 
     <developerConnection>scm:svn:https://my-svn-server/svn/maven-rnd/release-plugin-rnd/trunk</developerConnection> 
     <url>https://my-svn-server/svn/maven-rnd/release-plugin-rnd/trunk</url> 
    </scm> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-release-plugin</artifactId> 
       <configuration> 
        <tagBase>https://my-svn-server/svn/maven-rnd/release-plugin-rnd/tags</tagBase> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-deploy-plugin</artifactId> 
       <version>2.7</version> 
       <executions> 
        <execution> 
         <id>default-deploy</id> 
         <phase>deploy</phase> 
         <goals> 
          <goal>deploy</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

    <distributionManagement> 
     <snapshotRepository> 
      <id>snapshots</id> 
      <name>Internal Snapshots</name> 
      <url>http://my-nexus-server:9090/nexus/content/repositories/snapshots</url> 
     </snapshotRepository> 
     <repository> 
      <id>releases</id> 
      <name>Internal Releases</name> 
      <url>http://my-nexus-server:9090/nexus/content/repositories/releases</url> 
     </repository> 
    </distributionManagement> 

</project> 

回答

4

我沒有用鏡子功能的任何經驗,但我可以嘗試從當我設置了我們的私人公司幫助nexus服務器。當你在你的POM中指定一個ID應該匹配您在settings.xml中定義相同的ID。所以,你想要做的是這樣的:

<servers> 
     <server> 
      <id>terraframe-releases</id> 
      <username>myUsername</username> 
      <password>myPassword</password> 
     </server> 
     <server> 
      <id>terraframe-snapshots</id> 
      <username>myUsername</username> 
      <password>myPassword</password> 
     </server> 
     <server> 
      <id>terraframe-thirdparty</id> 
      <username>myUsername</username> 
      <password>myPassword</password> 
     </server> 
    </servers> 

在你的POM,那麼你引用這些相同的標識:

<distributionManagement> 
    <repository> 
     <id>terraframe-releases</id> 
     <name>terraframe-releases</name> 
     <url>http://terraframe.com:8081/nexus/content/repositories/releases/</url> 
     <layout>default</layout> 
    </repository> 
    <snapshotRepository> 
     <id>terraframe-snapshots</id> 
     <name>terraframe-snapshots</name> 
     <url>http://terraframe.com:8081/nexus/content/repositories/snapshots/</url> 
     <layout>default</layout> 
    </snapshotRepository> 
    </distributionManagement> 

另外,如果你是你自己的本地網絡上(後面路由器爲例)和URL http://my-nexus-server:9090正在內部託管(在本地主機或192.168地址),你更可能將無法打的本地服務器與外部域名http://my-nexus-server:9090所以一定要與本地主機指定它無處不在它要求它。

+0

感謝您的指導。有效! – user2325154

相關問題