Wil*_*lfi 5 nexus sonatype maven maven-archetype
我有一个私有Nexus,通过身份验证保护存储库.
拉动库就像一个魅力,但如果我想使用存储在那里的原型之一,我总是需要在原型目录的URL中写明文用户名和密码,如下所示:
mvn archetype:generate -DarchetypeCatalog=http://username:password@maven.mycompany.com/nexus/content/repositories/myrepo/archetype-catalog.xml
Run Code Online (Sandbox Code Playgroud)
我阅读了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>
Run Code Online (Sandbox Code Playgroud)
不用说,它不起作用,当我尝试时:
mvn archetype:generate -DarchetypeCatalog=http://maven.mycompany.com/nexus/content/repositories/myrepo/archetype-catalog.xml
Run Code Online (Sandbox Code Playgroud)
我老了:
[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
Run Code Online (Sandbox Code Playgroud)
有工作示例的任何提示或更好的文档?
如果您至少未指定,目前无法做到这一点-DarchetypeArtifactId.根据您链接的官方文档:
The server id used to download the artifact is [archetypeArtifactId]-repo
Run Code Online (Sandbox Code Playgroud)
因此,如果密码受到保护(并且您不愿意在shell历史记录中公开用户名/密码),则无法浏览目录.
同时,您可以继续投票选择ARCHETYPE-204.他们有一个补丁已经可用多年,他们可能只是需要一点点推动.
UPDATE
查看maven原型项目的源代码,看起来下面的代码片段settings.xml可能适用于您:
<servers>
<server>
<id>archetype</id>
<username>${your username}</username>
<password>${your password}</password>
</server>
</servers>
Run Code Online (Sandbox Code Playgroud)
在获取远程目录archetype时构建Repository对象时存在默认ID .我不认为这是处理这种情况的官方方式,而且IMO有点脏.但它可能仍然适合你:-)
此外,您应该能够设置配置文件以重用archetype不同服务器的ID.
| 归档时间: |
|
| 查看次数: |
7014 次 |
| 最近记录: |