我正在为 Maven 部署 Nexus 存储库,并在其上自定义原型(prototype)。
我要执行 mvn archetype:generate
并被提示一个内部 + 自定义原型(prototype)的列表。
我发现提示自定义原型(prototype)的唯一方法(以符合人体工程学的方式,意味着没有 URL)是将原型(prototype)目录路径定义为设置中的属性。这不是一个有效的解决方案,因为我想要几个目录(并且这个属性不能在 CLI 中被覆盖)。
有没有人知道如何做到这一点?
提前致谢,
[编辑]
我发现了一个相关的问题报告:http://jira.codehaus.org/browse/ARCHETYPE-273
我注意到在 archetype:generate
期间, maven 尝试到达中央存储库:
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2
它以“连接超时”结束,因为我没有(也不想)指定代理......
我不明白为什么maven不检查nexus目录......
最佳答案
我还配置了一个 Nexus 来镜像 Maven 存储库,因此也可以镜像远程目录。
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://afbwt03:8081/nexus/content/groups/JavaRepo/</url>
</mirror>
和:
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
只有当我使用以下 Maven 命令行时,我才能访问远程目录:
mvn archetype:generate -DarchetypeCatalog=http://afbwt03:8081/nexus/content/groups/JavaRepo
如果我不定义
archetypeCatalog
变量,我得到与您相同的行为:尝试访问 repo1. ...虽然配置了一些镜像。
关于Maven 原型(prototype)目录 : specify custom location(s),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6596621/