无法解析org.apache.maven.archetypes的版本

Har*_*oon 25 eclipse m2eclipse maven

我在本地机器上配置了maven3.0.3.已经安装了m2e eclipse插件.但是当我尝试使用maven-archetype-webapp创建一个新的maven项目时,我得到以下异常.

 Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE    from any of the configured repositories.
 Could not resolve artifact org.apache.maven.archetypes:maven-archetype- webapp:pom:RELEASE
 Failed to resolve version for org.apache.maven.archetypes:maven-archetype- webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype- webapp/maven-metadata.xml in local ([HOME]/.m2/repository)
 Failed to resolve version for org.apache.maven.archetypes:maven-archetype-  webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-  webapp/maven-metadata.xml in local ([HOME]/.m2/repository)
Run Code Online (Sandbox Code Playgroud)

我在代理后面进行一些处理,并更新代理配置 {HOME}/.m2/settings.xml and M2_HOME/conf/settings.xml.

archetype generate命令在命令行中正常工作.它通过代理下载了依赖项.

任何帮助是极大的赞赏.

编辑05-10-2012在eclipse中创建一个新的Maven Web项目时,原型"maven-archetype-webapp"版本显示为RELEASE.无论如何这是否相关?

Jus*_*bel 49

我有同样的问题.我通过将maven 原型目录添加到eclipse来修复它.步骤如下:

  1. 打开窗口>首选项
  2. 打开Maven> Archetypes
  3. 单击"添加远程目录"并添加以下内容:

  • 你的解决方案对我不起作用.最后我解决了这个问题:在http://stackoverflow.com/questions/25760961/cannot-create-maven-project-in-eclipse/25807975#25807975上查看我的回复中的详细步骤 (5认同)

Har*_*oon 4

我发现以下教程非常有用。

Step1:用于创建Web应用程序的maven命令: mvn archetype:generate -DgroupId=test.aasweb -DartifactId=TestWebApp -DarchetypeArtifactId=maven-archetype-webapp

步骤2:以下条目已添加到项目的pom.xml 中。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
    <wtpapplicationxml>true</wtpapplicationxml>
    <wtpversion>1.5</wtpversion>
    <downloadSources>true</downloadSources>
    <downloadJavadocs>true</downloadJavadocs>
        <classpathContainers>
            <classpathContainer>
                org.eclipse.jst.j2ee.internal.web.container
            </classpathContainer>
            <classpathContainer>
                org.eclipse.jst.j2ee.internal.module.container
            </classpathContainer>
        /classpathContainers>
        <additionalProjectFacets>
            <jst.web>2.5</jst.web>
            <jst.jsf>1.2</jst.jsf>
        </additionalProjectFacets>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

Step3:运行maven命令转换为eclipse项目格式。mvn eclipse:clean eclipse:eclipse

步骤4:将项目作为现有Maven项目导入到eclipse中。