[英]maven not picking username for repository from settings.xml
我的〜/ .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>
我面临的问题是没有部署工件,并且联系日志显示用于身份验证的用户名是“匿名”。 这就是为什么它会失败。 为什么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
如果在settings.xml中配置镜像,则必须在服务器元素中使用镜像的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>
如果存储库受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=
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.