eclipse 无法解析 org.apache.maven.archetypes 的版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12742467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to resolve version for org.apache.maven.archetypes
提问by Haroon
I have configured maven3.0.3 in my local machine. Have installed m2e eclipse plugin. But when i try to create a new maven project using maven-archetype-webapp, i get the following exception.
我已经在我的本地机器上配置了 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)
I do some processing behind a proxy and the proxy configurations are updated in {HOME}/.m2/settings.xml and M2_HOME/conf/settings.xml.
我在代理后面做了一些处理,代理配置在 {HOME}/.m2/settings.xml and M2_HOME/conf/settings.xml.
The archetype generate command works fine in command line. It downloaded the dependencies through proxy.
原型生成命令在命令行中工作正常。它通过代理下载了依赖项。
Any help is greatly appreciated.
任何帮助是极大的赞赏。
Edit 05-10-2012 While creating a new Maven Web project in eclipse, the archetype "maven-archetype-webapp" version is displayed as RELEASE. Is this in anyway linked?
编辑 05-10-2012 在 eclipse 中创建新的 Maven Web 项目时,原型“maven-archetype-webapp”版本显示为 RELEASE。这有什么联系吗?
回答by Justin Wrobel
I had the same problem. I fixed it by adding the maven archetype catalogto eclipse. Steps are provided below:
我有同样的问题。我通过将 maven原型目录添加到 eclipse 来修复它。步骤如下:
- 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
- 打开窗口 > 首选项
- 打开 Maven > 原型
- 单击“添加远程目录”并添加以下内容:
- 目录文件:http: //repo1.maven.org/maven2/archetype-catalog.xml
- 描述:maven 目录
回答by Haroon
I found the following tutorialvery useful.
我发现以下教程非常有用。
Step1: The maven command used to create the web app: mvn archetype:generate -DgroupId=test.aasweb -DartifactId=TestWebApp -DarchetypeArtifactId=maven-archetype-webapp
Step1:用于创建web应用的maven命令: mvn archetype:generate -DgroupId=test.aasweb -DartifactId=TestWebApp -DarchetypeArtifactId=maven-archetype-webapp
Step2: The following entry was added onto the project's pom.xml.
步骤 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>
Step3: Run the maven command to convert into eclipse project format. mvn eclipse:clean eclipse:eclipse
Step3:运行maven命令转换为eclipse项目格式。mvn 日食:清洁日食:日食
Step4: Import the project onto eclipse as Existing Maven project.
Step4:将项目作为Existing Maven project导入eclipse。
回答by ShrekWang
Read carefully about the reason.
仔细阅读原因。
"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.xmlin local"
“无法解析 org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: 无法在本地找到元数据 org.apache.maven.archetypes:maven-archetype-webapp/ maven-metadata.xml”
So all you need to do is download the maven-metadata.xmlto your {HOME}.m2\repository
所以你需要做的就是将maven-metadata.xml下载 到你的 {HOME}.m2\repository
That's it.
就是这样。
回答by Jared Smith
You do need to have a settings.xml linked under user settings (Located in preferences under maven)
您确实需要在用户设置下链接一个 settings.xml(位于 maven 下的首选项中)
But, if that doesn't fix it, like it didn't for many of you. You also have to delete the directory:
但是,如果这不能解决问题,就像你们中的许多人一样。您还必须删除目录:
.m2/repository/org/apache/maven/archetypes/maven-archetype-quickstart
.m2/repository/org/apache/maven/archetypes/maven-archetype-quickstart
then quit eclipse and try again.
然后退出eclipse并重试。
This is what solved my problem.
这就是解决我的问题的原因。
回答by jzarsuelo
If you are using eclipse, you can follow the steps here (maven in 5 min not working) for getting your proxy information. Once done follow the steps below:
如果您使用的是 eclipse,您可以按照此处的步骤(5 分钟内 maven 不起作用)获取您的代理信息。完成后,请按照以下步骤操作:
- Go to Maven installation folder
C:\apache-maven-3.1.0\conf\
- Copy
settings.xml
toC:\Users\[UserFolder]\.m2
Modify the proxy in
settings.xml
based on the info that you get from the above link.<proxy> <active>true</active> <protocol>http</protocol> <host>your proxy</host> <port>your port</port> </proxy>
Open eclipse
Go to: Windows > Preferences > Maven > User Settings
Browse the
settings.xml
from.m2
folderClick
Update Settings
Click
Reindex
Apply the changes and Click
OK
- 进入Maven安装文件夹
C:\apache-maven-3.1.0\conf\
- 复制
settings.xml
到C:\Users\[UserFolder]\.m2
settings.xml
根据您从上述链接获得的信息修改代理。<proxy> <active>true</active> <protocol>http</protocol> <host>your proxy</host> <port>your port</port> </proxy>
打开日食
转到:Windows > 首选项 > Maven > 用户设置
浏览
settings.xml
来自.m2
文件夹点击
Update Settings
点击
Reindex
应用更改并单击
OK
You can now try to create Maven Project in Eclipse
您现在可以尝试在 Eclipse 中创建 Maven 项目
回答by Ashish Kumar
Go to Windows-> Preference-> Maven -> User settings
转到 Windows-> 首选项-> Maven -> 用户设置
Select settings.xml of Maven
选择Maven的settings.xml
Restart Eclipse
重启 Eclipse
回答by Hemanth Kumar
I had the same problem i solved it by only adding remote catalog
in eclipse go to Window -> Preferences ->Maven ->Archetypes ->click on add remote Catalog then a window will open in that paste
http://repo.maven.apache.org/maven2/archetype-catalog.xmlin that catalog file then hit ok restart eclipse now all working fine
我遇到了同样的问题,我只通过在 eclipse 中添加远程目录来解决它,转到窗口 -> 首选项 -> Maven -> 原型 -> 单击添加远程目录,然后将在该粘贴
http://repo.maven 中打开一个窗口。 apache.org/maven2/archetype-catalog.xml在那个目录文件中然后点击确定重启 eclipse 现在一切正常
回答by Elias
The right way to solve my problem are as followed. Hope to be helpful to others. the errors informations.
解决我的问题的正确方法如下。希望对其他人有所帮助。错误信息。
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories. Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories. Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Delete the maven-archetype-webapp:1.0 in the directory ~/.m2/repository/org/Apache/maven/archetypes
Download the maven-archetype-webapp:1.0 and the maven-archetype-webapp-1.0.pom from http://maven.ibiblio.org/maven2/org/apache/maven/archetypes/maven-archetype-webapp/1.0/
execute mvn install:install-file -DgroupId=org.apache.maven.archetypes -DartifactId=maven-archetype-quickstart -Dversion=1.1 -Dpackaging=jar -Dfile=此处填maven-archetype-webapp-1.0的路径.
try to establish a maven project of webapp to test whether the problem has solved.
删除 ~/.m2/repository/org/Apache/maven/archetypes 目录下的 maven-archetype-webapp:1.0
从http://maven.ibiblio.org/maven2/org/apache/maven/archetypes/maven-archetype-webapp/1.0/下载 maven-archetype-webapp:1.0 和 maven-archetype-webapp-1.0.pom
执行mvn install:install-file -DgroupId=org.apache.maven.archetypes -DartifactId=maven-archetype-quickstart -Dversion=1.1 -Dpackaging=jar -Dfile=此处填maven-archetype-webapp-1.0的路径。
尝试建立webapp的maven项目,测试问题是否解决。
回答by xerXes
Create New User Environment Variables:
创建新的用户环境变量:
MAVEN_HOME=D:\apache-maven-3.5.3
MAVEN=D:\apache-maven-3.5.3\bin
MAVEN_OPTS=-Xms256m -Xmx512m
Appened below in Path variable (System Variable):
附加在路径变量(系统变量)中:
;D:\apache-maven-3.5.3\bin;
回答by dagmawi tadesse
This worked for me:- navigate to windows-> preferences-> maven and check the "download artifacts sources" and click apply.
这对我有用:- 导航到 windows-> 首选项-> maven 并检查“下载工件源”并单击应用。