我刚刚在我的Windows Tomcat上安装了Nexus 2.7.1并启动并运行 . 我正在尝试使用“maven deploy”命令将SNAPSHOT jar部署到Nexus快照存储库,但会出现以下错误 . 使用Maven 3.0.5版 . 请指导 .
*[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project release-plugin-rnd: Failed to deploy artifacts: Could not transfer artifact 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): Failed to transfer file: http://my-nexus-server.com:9090/nexus/content/repos itories/snapshots/com/study/release-plugin-rnd/1.3-SNAPSHOT/release-plugin-rnd-1.3-20140218.193240-1.jar. Return code is: 401, ReasonPhrase: Unauthorized. - > [帮助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 回答
我对镜像功能没有任何经验,但是当我设置我们的私人公司nexus服务器时,我可以尝试提供帮助 . 在pom中指定id时,它应该与您在settings.xml中定义的id相同 . 所以你想要做的是这样的:
然后在你的pom中引用那些相同的id:
此外,如果您在自己的本地网络(例如路由器后面)并且url
http://my-nexus-server:9090
正在内部托管(在localhost或192.168 . 地址上),您很可能无法访问该本地服务器使用外部域名http://my-nexus-server:9090
,因此请确保在所有要求的地方使用localhost指定它 .