3

我正在 Eclipse 中开发项目并且我正在使用 maven,所以我使用 ' maven-archetype-archetype ' Archetype创建了一个新原型,但是一旦我尝试使用我的新原型创建一个新项目,我在 Eclipse 中得到以下错误消息:

The META-INF/maven/archetype.xml descriptor cannot be found.

知道原因是什么吗?

更新:

我的archetype.xml 文件:

<archetype>
    <id>test-archetype</id>
    <sources>
        <source>src/</source>
    </sources>
    <testSources>
        <source>test/</source>
    </testSources>
</archetype>

我的 pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>$my.group.id</groupId>
    <artifactId>$test-archetype</artifactId>
    <version>$0.0.1</version>


    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

文件夹结构如下所述:

archetype
|-- pom.xml
`-- src
    `-- main
        `-- resources
            |-- META-INF
            |   `-- maven
            |       `--archetype.xml
            `-- archetype-resources
                |-- pom.xml
                `-- src
                `-- test    

亚当。

4

5 回答 5

4

我遇到了完全相同的问题,即 Eclipse 会报告无法找到 archetype.xml,即使它确实存在于正确的位置。重新启动 Eclipse 后,我终于让它工作了。似乎如果原型项目安装/部署在与它用于创建它错误的项目相同的 Eclipse 会话中。

于 2012-12-27T20:42:32.290 回答
2

问题是您(或 Eclipse)似乎正在使用“mvn archetype:create”命令来创建已被弃用的新项目。

您应该改用“mvn archetype:generate”

http://maven.apache.org/archetype/maven-archetype-plugin/plugin-info.html

于 2012-08-23T04:59:03.583 回答
0

如果您正在使用 Eclipse,请尝试使用Eclipse IAM,它具有简单的向导和现成的 maven 解决方案,并且与 eclipse 的集成度很好。

于 2011-02-01T02:19:20.803 回答
0

这似乎是与 Eclipse 中的 Maven 存储库相关的错误。也许它已在较新版本的 eclipse 中修复。

这是一个解决方法:

  1. 生成新原型时,增加原型版本(例如,从 0.0.1-SNAPSHOT 到 0.0.2-SNAPSHOT)。在 mvn install 之后,新的原型版本将出现在 Workspace Projects 中,但不会出现在 Local Repository 中。

  2. 在本地存储库上重建索引。新的原型版本现在将出现在本地存储库中并可供使用。

于 2016-01-23T08:07:19.513 回答
-1

我最近再次尝试过,现在我对 Maven 的经验更加丰富,结果是一样的,据我所知,制作原型存在问题,可能是 Eclipse 错误,或者错过了配置,但是无论我尝试了什么,它都没有成功。

于 2011-07-24T13:49:04.017 回答