首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"Maven in 5分钟“教程中的原型插件错误

"Maven in 5分钟“教程中的原型插件错误
EN

Stack Overflow用户
提问于 2018-07-13 22:30:42
回答 1查看 845关注 0票数 2

我正在尝试5分钟内教程,并且几乎立即遇到了一个错误。mvn --version的结果如下

代码语言:javascript
复制
Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 1.8.0_171, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-23-generic", arch: "amd64", family: "unix"

当我运行教程中的下一个命令时,

代码语言:javascript
复制
$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app \
   -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

我得到以下错误:

代码语言:javascript
复制
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli)
on project standalone-pom: archetypeCatalog 'http://mavenrepo.openmrs.org/nexus/content/repositories/public/archetype-catalog.xml'
is not supported anymore. Please read the plugin documentation for details. -> [Help 1]

其中“帮助1”只是MojoFailureException文档

看起来,原型插件发布了一个突破性的变化,而且Maven教程还没有被更新以反映这一点。但有趣的是,Quickstart原型的文档建议的命令,

代码语言:javascript
复制
$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.3

同样的错误也会失败。

是否仍然可以基于Quickstart原型生成maven项目,如果可以,我如何实现?

编辑:这是我的~/.m2/settings.xml文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>${env.BINTRAY_USER}</username>
      <password>${env.BINTRAY_API_KEY}</password>
      <id>bintray-sdk</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <properties>
        <archetypeRepository>http://mavenrepo.openmrs.org/nexus/content/repositories/public</archetypeRepository>
        <archetypeCatalog>http://mavenrepo.openmrs.org/nexus/content/repositories/public/archetype-catalog.xml</archetypeCatalog>
      </properties>
      <repositories>
        <repository>
          <id>openmrs-repo</id>
          <name>OpenMRS Nexus Repository</name>
          <url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
        </repository>
        <repository>
          <id>openmrs-repo-thirdparty</id>
          <name>OpenMRS Thirdparty Nexus Repository</name>
          <url>http://mavenrepo.openmrs.org/nexus/content/repositories/thirdparty</url>
        </repository>
        <repository>
          <id>openmrs-bintray-repo</id>
          <name>OpeMRS Maven Bintray Repository</name>
          <url>https://dl.bintray.com/openmrs/maven/</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>openmrs-repo</id>
          <name>OpenMRS Nexus Repository</name>
          <url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
        </pluginRepository>
        <pluginRepository>
          <id>openmrs-bintray-repo</id>
          <name>OpeMRS Maven Bintray Repository</name>
          <url>https://dl.bintray.com/openmrs/maven/</url>
        </pluginRepository>
      </pluginRepositories>
      <id>openmrs</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>openmrs</activeProfile>
  </activeProfiles>
  <pluginGroups>
    <pluginGroup>org.openmrs.maven.plugins</pluginGroup>
  </pluginGroups>
</settings>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-18 11:47:00

实际上,正如错误消息所建议的那样,不推荐使用archetypeCatalog。您必须将属性archetypeRepositoryarchetypeCatalogsettings.xml中删除,并使用archetype声明存储库为id,如下所示:

代码语言:javascript
复制
<settings>
    <profile>
        <id>openmrs</id>
        <repositories>
            <repository>
                <id>archetype</id>
                <url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url>
            </repository>
            <!-- keep other repositories -->
        </repositories>
    </profile>
</settings>

您的活动配置文件是openmrs,因此应该使用此配置找到原型,因为它们存在于openmrs存储库中(参见https://mavenrepo.openmrs.org/nexus/content/repositories/public/org/apache/maven/archetypes/)。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51333580

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档