【问题标题】:Maven reports 'The desired archetype does not exist' when using archetype from bintray当使用来自 bintray 的原型时,Maven 报告“所需的原型不存在”
【发布时间】:2017-08-17 23:14:24
【问题描述】:

首先,我将原型安装到我的本地存储库:

mvn dependency:get \
   -Dartifact=org.teavm.flavour:teavm-flavour-application:0.1.0-dev-8 \ 
   -DremoteRepositories=teavm::::https://dl.bintray.com/konsoletyper/teavm

其次,我运行原型生成:

mvn -DarchetypeCatalog=local \
  -DarchetypeGroupId=org.teavm.flavour \
  -DarchetypeArtifactId=teavm-flavour-application \
  -DarchetypeVersion=0.1.0-dev-8 \
  archetype:generate

并得到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.0:generate
(default-cli) on project standalone-pom: The desired archetype does not exist 
(org.teavm.flavour:teavm-flavour-application:0.1.0-dev-8) -> [Help 1]

当我从源代码构建项目并生成 SNAPSHOT 原型时,一切正常。

是我做错了什么,还是 Maven 中的错误?有解决办法吗?

【问题讨论】:

    标签: maven maven-archetype bintray


    【解决方案1】:

    请转至https://bintray.com/konsoletyper/teavm/teavm-flavour-dev

    然后点击设置我!

    然后选择:使用 Maven 解决工件

    将此部分复制到您的设置 xml 中(通常位于 /Users/os-username/.m2/settings.xml 见下文):

    <profiles>
            <profile>
                <repositories>
                    <repository>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                        <id>bintray-konsoletyper-teavm</id>
                        <name>bintray</name>
                        <url>http://dl.bintray.com/konsoletyper/teavm</url>
                    </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                        <id>bintray-konsoletyper-teavm</id>
                        <name>bintray-plugins</name>
                        <url>http://dl.bintray.com/konsoletyper/teavm</url>
                    </pluginRepository>
                </pluginRepositories>
                <id>bintray</id>
            </profile>
        </profiles>
        <activeProfiles>
            <activeProfile>bintray</activeProfile>
        </activeProfiles>
    

    然后再试第二个命令。

    settings.xml:

    settings.xml 文件可能存在两个位置:

    Maven 安装:${maven.home}/conf/settings.xml

    一个用户的安装:${user.home}/.m2/settings.xml

    https://maven.apache.org/settings.html

    【讨论】:

    • 这行得通!但原因是什么?当我手动下载依赖项时,Maven 在本地存储库中看不到原型,即使在我运行 archetype:crawl 之后也是如此。另外,我必须向我的用户解释如何更新他们的settings.xml,而不是只提供单个命令行 sn-p。
    • 我不确定到底是什么问题,但似乎 mv 不知道查看您的 bintray 存储库,除非您在 settings.xml 中配置它。我已经为archetype:generate命令尝试了多个命令行参数,例如更改archetypeCatalog,但没有成功。也许将 archetype-catalog.xml 添加到您的存储库的根目录并将 archetypeCatalog 设置为您的存储库根目录/目录文件会有所帮助。另外,看看这里,它可能有一些很好的知识。 maven.apache.org/archetype/maven-archetype-plugin/specification/…祝你好运...
    • 对于你的用户,如果你将你的包链接到 JCenter 并使用二进制的自动同步到 maven Central,我猜你的用户不需要在他们的 settings.xml 中改变任何东西,因为所有文件都会默认情况下可以发现 Maven 客户端。 bintray.com/docs/usermanual/uploads/…
    • 我使用 bintray 发布预览版本,我不想在 Maven Central 上发布。
    • 这很奇怪。即使我删除了本地的archetype-catalog.xml,我仍然可以使用本地构建的原型,但是当我将这些原型下载到本地存储库时,Maven 无法识别它们。 Maven 将它们视为工件,而不是原型。
    【解决方案2】:

    我遇到了同样的问题,并通过添加插件“Maven Archetype Catalogs”来修复它,该插件可以获取外部原型目录文件。

    点击 ⌘、(macOS) 或 Ctrl+Alt+S (Windows/Linux) 转到 Preferences,然后点击 Plugins 并查找 Maven Archetype Catalogs。 p>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-02
      • 1970-01-01
      • 2016-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多