当我执行此命令来构建项目(Mac OS X)时:
/usr/local/Cellar/maven@3.5/3.5.4/libexec/bin/mvn clean package -Dmaven.test.skip=true -U
引发此错误:
Could not transfer metadata com.sports.soa:soa-room-api:1.0.0-SNAPSHOT/maven-metadata.xml from/to snapshots (http://nexus.example.com/repository/maven-snapshots/): Not authorized , ReasonPhrase:Unauthorized.
我已经在设置xml中配置授权信息:
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
这是我的pom.xml配置:
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Releases Repository Pro</name>
<url>http://nexus.example.com/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshots Repository Pro</name>
<url>http://nexus.example.com/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
该如何解决该问题(我已经尝试过加密密码,无法使用)?谢谢。通过这种方式,我可以使用浏览器中的配置密码来浏览存储库。我的存储库配置为:< / p>
<repositories>
<repository>
<id>snapshots</id>
<name>Snapshots</name>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://nexus.example.com/repository/maven-snapshots/</url>
</repository>
<repository>
<id>releases</id>
<name>Releases</name>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nexus.example.com/repository/maven-releases/</url>
</repository>
</repositories>
答案 0 :(得分:0)
将回购ID更改为nexus-releases
,然后nexus-snapshots
解决此问题:
<repositories>
<repository>
<id>nexus-snapshots</id>
<name>Snapshots</name>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://nexus.example.com/repository/maven-snapshots/</url>
</repository>
<repository>
<id>nexus-releases</id>
<name>Releases</name>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://nexus.example.com/repository/maven-releases/</url>
</repository>
</repositories>