无法将快照工件部署到nexus

时间:2014-02-18 20:00:10

标签: maven nexus maven-deploy-plugin

我刚在Windows Tomcat上安装了Nexus 2.7.1并启动并运行。我正在尝试使用“maven deploy”命令将SNAPSHOT jar部署到Nexus快照存储库,但会出现以下错误。使用Maven 3.0.5版。请指导。

[错误]无法在项目release-plugin-rnd上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy(default-deploy):无法部署工件:无法执行转移工件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 /快照/ COM /学习/释放-插件,RND / 1.3-SNAPSHOT /释放-插件-RND-1.3-20140218.193240-1.jar。 * 返回代码是:401,ReasonPhrase:未经授权。 - > [帮助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>

1 个答案:

答案 0 :(得分: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中引用那些相同的ID:

 <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正在内部托管(在localhost或192.168。地址上),你很可能不会能够使用外部域名http://my-nexus-server:9090命中该本地服务器,因此请确保在所要求的任何地方使用localhost指定它。