Maven 原型(prototype)目录 : specify custom location(s)

标签 maven nexus maven-archetype

我正在为 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/

相关文章:

java - SPRING 处理 JSP 页面时发生异常

java - 如何在 Java 中使用 Ruby 和 Maven?

version-control - 您如何确保使用诸如 nexus 或 artifactory 之类的 Artifactory 存储库与将库检查到源代码控制中的可重复构建?

gradle - Gradle发现POM依赖但不是JAR

java - webapp 的 Maven 原型(prototype)

Maven 原型(prototype)不使用属性来创建模块名称

java - 如何在maven spring boot应用程序中查看lombok生成的类

java - Tomcat7 maven 插件-处理请求时捕获 I/O 异常 (java.net.SocketException) : Broken pipe

maven - 如何提供对 Nexus 2.x 中 Artifact 的最新快照的 URL 访问?

maven - 如何在 Maven 中使用我的自定义原型(prototype)?