gpt4 book ai didi

java - "Maven in 5 Minutes"教程中的原型(prototype)插件错误

转载 作者:行者123 更新时间:2023-11-30 07:45:45 24 4
gpt4 key购买 nike

我正在尝试 Maven in 5 Minutes教程并几乎立即遇到错误。 mvn --version 的结果是

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"

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

$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app \
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

我收到以下错误:

[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”就是 docs for MojoFailureException .

似乎 archetype 插件发布了重大更改,而 Maven 教程尚未更新以反射(reflect)这一点。虽然,有趣的是,docs for the Quickstart Archetype 建议的命令,

$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.3

同样的错误也失败了。

是否仍然可以基于 Quickstart 原型(prototype)生成 Maven 项目,如果可以,我该怎么做?

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

<?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>

最佳答案

实际上,正如错误消息所暗示的那样,不推荐使用 archetypeCatalog。您必须从 settings.xml 中删除属性 archetypeRepositoryarchetypeCatalog,并将 archetype 声明为 id,像这样:

<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>

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

关于java - "Maven in 5 Minutes"教程中的原型(prototype)插件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51333580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com