我的〜/.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>
我面临的问题是没有部署 Artifact ,并且联系日志显示用于身份验证的用户名是“匿名”。这就是为什么它会失败。为什么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>