在Eclipse中创建一个Maven项目抱怨“无法解析原型” [英] Create a Maven project in Eclipse complains "Could not resolve archetype"
问题描述
我想用Eclipse Juno EE与原型webapp创建一个Maven项目。我安装了Maven Integration for Eclipse WTP(孵化),我还安装了Maven Integration for Eclipse(在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:\Documents and Settings\PEP35KD\m2\repository)中找到元数据org.apache.maven.archetypes:maven-archetype-webapp / maven-metadata.xml
无法解析org.apache.maven.archetypes的版本:maven-archetype-webapp:pom:RELEASE:找不到本地的元数据org.apache.maven.archetypes:maven-archetype-webapp / maven-metadata.xml(C :\Documents and Settings\PEP35KD\.m2\repository)
它适用于各种原型。
我正在使用代理,我在C:\Documents和Settings\PEP35KD.m2\下创建文件settings.xml,其中包含:
<代理>
<代理>
< id> myId< / id>
< active> true< / active>
< protocol> http< / protocol>
< username> rete\pep35kd< / username>
< password> XXXX< / password>
< host> XXXX< / host>
< port> 8080< / port>
< nonProxyHosts> localhost< / nonProxyHosts>
< / proxy>
< /代理>
请注意,似乎我无法使用命令行中的mvn命令(命令未找到)。我从来没有安装过Maven,我认为这个插件就够了,这是否是一个正确的假设?
更新问题绝对与代理相关。通过:
- 在本地PC上安装Maven;
- 从Eclipse安装Maven Eclipse
市场; - 设置Maven将目录安装到本地PC Maven目录,而不是默认的Embedded Maven,
一切都符合预期。我不明白为什么,但是防火墙可能会阻止Maven服务器的流量。
我通过以下解决方案来解决这个问题其他StackOverflow问题
我有同样的问题。我通过将maven原型目录添加到eclipse来修复它。步骤如下:
- 打开窗口>首选项
- 打开Maven>原型
- 点击添加远程目录,并添加以下内容:
- 目录文件: http://repo1.maven.org/maven2/archetype-catalog.xml
- 说明:maven目录
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 Settings\PEP35KD\.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 (C:\Documents and Settings\PEP35KD\.m2\repository)
It happens for all kinds of archetype. I am using a proxy, and I create file settings.xml under C:\Documents and Settings\PEP35KD.m2\ with this content:
<proxies>
<proxy>
<id>myId</id>
<active>true</active>
<protocol>http</protocol>
<username>rete\pep35kd</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:
- Open Window > Preferences
- Open Maven > Archetypes
- Click 'Add Remote Catalog' and add the following:
- Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml
- Description: maven catalog
这篇关于在Eclipse中创建一个Maven项目抱怨“无法解析原型”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!