【问题标题】:Can't create a project from an archetype-catalog.xml无法从 archetype-catalog.xml 创建项目
【发布时间】:2018-03-17 15:17:06
【问题描述】:

我正在尝试使用我自己的项目模板,但是当我执行命令时:

mvn archetype:generate -DarchetypeCatalog=local

我收到以下消息:

 [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.
archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
   Your filter doesn't match any archetype (hint: enter to return to initial list)
Choose a number or apply filter (format: [groupId:]artifactId, case-sensitive contains): :

我尝试了许多我在这里找到的可能的解决方案,但我没有成功......

我的步骤:
- 我在eclipse中创建了一个项目
- 然后我进入这个项目的根目录并在提示符下执行以下命令:

mvn archetype:create-from-project

并取得了成功。


然后我对项目的文件夹执行了以下命令

mvn install

并取得了成功


我检查了 .m2 文件夹,archetpe-catalog.xml 在那里:

<?xml version="1.0" encoding="UTF-8"?>
<archetype-catalog xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd"
    xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <archetypes>
    <archetype>
      <groupId>io.openbdt</groupId>
      <artifactId>framework-openbdt</artifactId>
      <version>1.0</version>
      <description>framework-openbdt</description>
    </archetype>
  </archetypes>
</archetype-catalog>

在 maven 的文档中解释说 archetypeCatalog=local 的默认路径是 path/.m2/archetype-catalog.xml 但在调试中(mvn archetype:generate -DarchetypeCatalog= local -X),maven在path/.m2/repository/archetype-catalog.xml

中搜索xml文件

注意:这些步骤通常在我的笔记本中执行,但在我的桌面上我没有成功。然后我在笔记本上创建了一个新用户,它也不再工作了。

有人可以帮帮我吗?

【问题讨论】:

  • 有时 maven 在 Eclipse 上不能正常工作,你应该在构建项目之前构建 maven
  • 有一个命令但我不记得了,ctr alt f5 之类的,否则试试 mvn build

标签: java xml maven archetypes xmlcatalog


【解决方案1】:

我遇到了完全相同的问题,并在 Maven 版本 3.3.9 和 3.5.2 中重现了它。 mvn installmvn archetype:generate 处理 archetype-catalog.xml 的方式可能不一致。

因为对我也没有任何帮助,所以我创建了一个软链接:

ln -s PATH/TO/.m2/archetype-catalog.xml PATH/TO/.m2/repository/archetype-catalog.xml

这对我来说是个窍门。不幸的是,这只适用于类 Unix 系统。

【讨论】:

    【解决方案2】:

    Maven 3.5.2 读写位置不一致。

    当在settings.xml 中设置localRepository 时,mvn archetype:generate -DarchetypeCatalog=local 命令读取${localRepository}/archetype-catalog.xml

    当没有localRepository 设置时,该命令读取~/.m2/archetype-catalog.xml


    mvn archetype:update-local-catalog 命令用maven-archetype-plugin 创建~/.m2/archetype-catalog.xml v2.4

    该命令使用 v3.0.1 创建${localRepository}/archetype-catalog.xml


    参考: [ARCHETYPE-529] Maven archetype:generate does not find local archetypes in interactive mode - ASF JIRA

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-17
      • 1970-01-01
      • 2022-12-20
      • 2010-10-11
      • 2015-10-14
      • 1970-01-01
      • 2011-09-20
      • 1970-01-01
      相关资源
      最近更新 更多