我有一个私有 Nexus,其存储库通过身份验证保护。
拉取库就像一个魅力,但如果我想使用其中存储的原型之一,我总是需要在原型目录的 URL 中写入纯文本用户名和密码,如下所示:
mvn archetype:generate -DarchetypeCatalog=http://username:password@maven.mycompany.com/nexus/content/repositories/myrepo/archetype-catalog.xml
我阅读了http://maven.apache.org/archetype/maven-archetype-plugin/faq.html#authentication并用我从那一点点帮助中了解到的内容更新了我的 settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>myrepo</id>
<username>username</username>
<password>{HASHED_PASSWORD}</password>
</server>
<server>
<id>pretty-archetype-unicorn-repo</id>
<username>username</username>
<password>{HASHED_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>someid</id>
<repositories>
<repository>
<id>myrepo</id>
<name>My Repo</name>
<url>http://maven.mycompany.com/nexus/content/repositories/myrepo/</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>someid</activeProfile>
</activeProfiles>
</settings>
不用说,它不起作用,当我尝试时:
mvn archetype:generate -DarchetypeCatalog=http://maven.mycompany.com/nexus/content/repositories/myrepo/archetype-catalog.xml
我得到同样的旧:
[WARNING] Error reading archetype catalog http://maven.mycompany.com/nexus/content/repositories/myrepo/archetype-catalog.xml
org.apache.maven.wagon.authorization.AuthorizationException: Access denied to: http://maven.mycompany.com/nexus/content/repositories/myrepo/archetype-catalog.xml
任何提示,或带有工作示例的更好文档?