在 Eclipse 中创建 Maven 项目抱怨“无法解析原型" [英] Create a Maven project in Eclipse complains "Could not resolve archetype"

查看:41
本文介绍了在 Eclipse 中创建 Maven 项目抱怨“无法解析原型"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全是 Maven 的新手.我想用 Eclipse Juno EE 和原型webapp"创建一个 Maven 项目.我安装了Eclipse WTP 的 Maven 集成(孵化)",并且我还安装了Eclipse 的 Maven 集成"(在 Eclipse Marketplace 的已安装选项卡上找到了它).当我尝试从 File->New_>Maven Project 创建新项目时,出现错误:

<前>无法从任何配置的存储库解析原型 org.apache.maven.archetypes:maven-archetype-webapp:RELEASE.无法解析工件 org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE无法解析 org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: 无法在本地 (C) 中找到元数据 org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml:Documents and SettingsPEP35KD.m2 epository)无法解析 org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: 无法在本地 (C) 中找到元数据 org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml:Documents and SettingsPEP35KD.m2 epository)

它发生在各种原型中.我正在使用代理,并使用以下内容在 C:Documents and SettingsPEP35KD.m2 下创建文件 settings.xml:

<代理><代理><id>myId</id><active>true</active><protocol>http</protocol><用户名>retepep35kd</用户名><密码>XXXX</密码><host>XXXX</host><端口>8080</端口><nonProxyHosts>localhost</nonProxyHosts></代理></代理>

请注意,我似乎无法从命令行使用 mvn 命令(未找到命令).我从来没有安装Maven本身,我认为插件就足够了:这是一个正确的假设吗?

UPDATE 问题肯定与代理有关.作者:

  • 在本地 PC 上安装 Maven;
  • 从 Eclipse 安装 Maven Eclipse市场;
  • 将 Maven 安装目录设置为本地 PC Maven 目录,而不是默认的嵌入式 Maven,

一切都按预期进行.我真的不明白为什么,但可能防火墙阻止了 Maven 服务器的流量.

解决方案

我按照 this other StackOverflow question的解决方案解决了这个问题

<块引用>

我遇到了同样的问题.我通过将 Maven 原型目录添加到 eclipse 来修复它.步骤如下:(请注意https协议)

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

I am totally a newbie with Maven. I want to create a Maven project with Eclipse Juno EE with archetype "webapp". I installed "Maven Integration for Eclipse WTP (incubation)" and I also have installed "Maven Integration for Eclipse" (found it on Installed tab of Eclipse Marketplace). When I try to create new Project from File->New_>Maven Project, I obtain error:

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 (C:Documents and SettingsPEP35KD.m2
epository)
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 (C:Documents and SettingsPEP35KD.m2
epository)

It happens for all kinds of archetype. I am using a proxy, and I create file settings.xml under C:Documents and SettingsPEP35KD.m2 with this content:

<proxies>
    <proxy>
        <id>myId</id>
        <active>true</active>
        <protocol>http</protocol>
        <username>retepep35kd</username>
        <password>XXXX</password>
        <host>XXXX</host>
        <port>8080</port>
        <nonProxyHosts>localhost</nonProxyHosts>
    </proxy>
</proxies>

Please, consider that it seems that I cannot use mvn command from command line (command not found). I never installed Maven itself, I thinked that plugin is just enough: is it a correct assumption?

UPDATE Problem is definitely related to proxy. By:

  • Installing Maven on local PC;
  • Installing Maven Eclipse from Eclipse Market Place;
  • Setting Maven Install directory to local PC Maven dir, instead of default Embedded Maven,

everything works as expected. I cannot really understand why, but probably firewall is blocking traffic with Maven servers.

解决方案

I fixed this problem by following the solution to this other StackOverflow question

I had the same problem. I fixed it by adding the maven archetype catalog to eclipse. Steps are provided below: (Please note the https protocol)

  1. Open Window > Preferences
  2. Open Maven > Archetypes
  3. Click 'Add Remote Catalog' and add the following:

这篇关于在 Eclipse 中创建 Maven 项目抱怨“无法解析原型"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆