我在〜/ .m2 / settings.xml中有这个:
<servers>
<server>
<username>deployment</username>
<password>xxxxxx</password>
<id>central</id>
</server>
<server>
<username>deployment</username>
<password>xxxxxx</password>
<id>snapshots</id>
</server>
</servers>
这在我的POM中:
<distributionManagement>
<repository>
<id>central</id>
<name>libs-release-local</name>
<url>http://repo.example.com:8081/nexus/content/repositories/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>libs-local</name>
<url>http://repo.example.com:8081/nexus/content/repositories/libs-local</url>
</snapshotRepository>
</distributionManagement>
我面临的问题是工件没有部署,nexus日志显示用于进行身份验证的用户名是“匿名的”。这就是它失败的原因。为什么maven没有选择在settings.xml中指定的用户名/密码,我做错了什么?
另外,我尝试使用-X运行maven,DEBUG日志说它正在读取设置的正确文件:
[DEBUG] Reading global settings from /home/praddy/apache-maven-3.0.5/conf/settings.xml
[DEBUG] Reading user settings from /home/praddy/.m2/settings.xml
[DEBUG] Using local repository at /home/praddy/.m2/repository
答案 0 :(得分:2)
如果repo受BasicAuth保护,你可以给它一个去:
将此添加到您的settings.xml
<servers>
<server>
<!-- Link this id here to the repo ID -->
<id>central</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<value>Basic ZGVwbG95bWVudDp4eHh4eHg=</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
您可以通过以下方式获取value
部分:
curl -v --user deployment:xxxxxx http://repo.example.com:8081/nexus/content/repositories/libs-release-local 2>&1 | grep Authorization
哪个输出应该类似于:
> Authorization: Basic ZGVwbG95bWVudDp4eHh4eHg=
答案 1 :(得分:2)
如果在settings.xml中配置镜像,则必须使用server元素中镜像的id。
<servers>
<server>
<id>MIRROR-ID</id>
<username>...</username>
<password>...</password>
</server>
</servers>
...
<mirrors>
<mirror>
<id>MIRROR-ID</id>
<name>...</name>
<url>...</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>