java - 无法从 archetype-catalog.xml 创建项目

标签 java xml maven archetypes xmlcatalog

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

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 3.5.2 读写位置不一致。

设置后localRepositorysettings.xml 中,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

关于java - 无法从 archetype-catalog.xml 创建项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46595180/

相关文章:

java - 当前 Java 连接池状态

java - Spring Boot 如何知道要注入(inject)哪个对象?

sql-server - SQL 服务器 2012 : Select xml with repeated and ungrouped set of elements

java - RESTful Jersey 请求的资源不可用

java - @TextIndexed 在 Spring/Maven 中?

java - 是否有任何 Java 库可以将访问者函数应用于前泛型集合的多个元素?

java - 如何使用 SpringTemplateLoader 而不是 FiletemPlateLoader 配置 Freemarker

xml - 如何使用 xslt 或 xpath 将注释添加到 xml 文件

c# - 如何将 <image> 检索到 xml 节点中?

java - 如何将文件夹/ja​​r 放置在 Maven META-INF 根目录中