简体   繁体   English

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

[英]Failed to resolve version for org.apache.maven.archetypes

I have configured maven3.0.3 in my local machine.我在我的本地机器上配置了 maven3.0.3。 Have installed m2e eclipse plugin.已安装 m2e eclipse 插件。 But when i try to create a new maven project using maven-archetype-webapp, i get the following exception.但是当我尝试使用 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. archetype generate 命令在命令行中运行良好。 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.编辑 05-10-2012 在 eclipse 中创建新的 Maven Web 项目时,原型“maven-archetype-webapp”版本显示为 RELEASE。 Is this in anyway linked?这到底有联系吗?

I had the same problem. 我有同样的问题。 I fixed it by adding the maven archetype catalog to eclipse. 我通过将maven 原型目录添加到eclipse来修复它。 Steps are provided below: 步骤如下:

  1. Open Window > Preferences 打开窗口>首选项
  2. Open Maven > Archetypes 打开Maven> Archetypes
  3. Click 'Add Remote Catalog' and add the following: 单击“添加远程目录”并添加以下内容:

I found the following tutorial very useful. 我发现以下教程非常有用。

Step1: The maven command used to create the web app: mvn archetype:generate -DgroupId=test.aasweb -DartifactId=TestWebApp -DarchetypeArtifactId=maven-archetype-webapp 步骤1:用于创建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. Step3:运行maven命令转换为eclipse项目格式。 mvn eclipse:clean eclipse:eclipse mvn eclipse:清除日食:日蚀

Step4: Import the project onto eclipse as Existing Maven project. Step4:将项目作为Existing Maven项目导入eclipse。

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.xml in local" “无法解析org.apache.maven.archetypes的版本:maven-archetype- webapp:pom:RELEASE:无法找到元数据org.apache.maven.archetypes:maven-archetype- webapp / maven-metadata.xml in local”

So all you need to do is download the maven-metadata.xml to your {HOME}.m2\\repository 所以你需要做的就是将maven-metadata.xml下载到你的{HOME} .m2 \\ repository

That's it. 而已。

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目录/库/组织/阿帕奇/行家/原型/ Maven的原型 - 快速入门

then quit eclipse and try again. 然后退出eclipse并再试一次。

This is what solved my problem. 这就解决了我的问题。

If you are using eclipse, you can follow the steps here ( maven in 5 min not working ) for getting your proxy information. 如果您使用的是eclipse,则可以按照此处的步骤( maven在5分钟内不工作 )来获取代理信息。 Once done follow the steps below: 完成后,请按照以下步骤操作:

  1. Go to Maven installation folder C:\\apache-maven-3.1.0\\conf\\ 转到Maven安装文件夹C:\\apache-maven-3.1.0\\conf\\
  2. Copy settings.xml to C:\\Users\\[UserFolder]\\.m2 settings.xml复制到C:\\Users\\[UserFolder]\\.m2
  3. Modify the proxy in settings.xml based on the info that you get from the above link. 根据您从上面的链接获得的信息修改settings.xml的代理。

     <proxy> <active>true</active> <protocol>http</protocol> <host>your proxy</host> <port>your port</port> </proxy> 
  4. Open eclipse 打开日食

  5. Go to: Windows > Preferences > Maven > User Settings 转到:Windows>首选项> Maven>用户设置

  6. Browse the settings.xml from .m2 folder .m2文件夹中浏览settings.xml

  7. Click Update Settings 单击Update Settings

  8. Click Reindex 单击Reindex

  9. Apply the changes and Click OK 应用更改并单击“ OK

You can now try to create Maven Project in Eclipse 您现在可以尝试在Eclipse中创建Maven项目

Go to Windows-> Preference-> Maven -> User settings 转到Windows-> Preference-> Maven - >用户设置

Select settings.xml of Maven 选择Maven的settings.xml

Restart Eclipse 重启Eclipse

I had a similar problem building from just command line Maven. 我从命令行Maven构建了类似的问题。 I eventually got past that error by adding -U to the maven arguments. 我最终通过在maven参数中添加-U来克服这个错误。

Depending on how you have your source repository configuration set up in your settings.xml, sometimes Maven fails to download a particular artifact, so it assumes that the artifact can't be downloaded, even if you change some settings that would give Maven visibility to the artifact if it just tried. 根据您在settings.xml中设置源存储库配置的方式,有时Maven无法下载特定工件,因此它假定无法下载工件,即使您更改了一些可以使Maven可见性的设置如果只是尝试过的神器。 -U forces Maven to look again. -U迫使Maven再次看。

Now you need to make sure that the artifact Maven is looking for is in at least one of the repositories that is referenced by your settings.xml. 现在,您需要确保Maven正在查找的工件至少位于settings.xml引用的一个存储库中。 To know for sure, run 要确定,请运行

mvn help:effective-settings

from the directory of the module you are trying to build. 从您尝试构建的模块的目录中。 That should give you, among other things, a complete list of the repositories you Maven is using to look for the artifact. 除了其他方面,这应该为您提供Maven用于查找工件的存储库的完整列表。

I too had same problem but after searching solved this. 我也有同样的问题,但搜索后解决了这个问题。 go to menu --> window-->preferences-->maven-->Installations-->add--> in place of installation home add path to the directory in which you installed maven-->finish-->check the box of newly added content-->apply-->ok. 转到菜单 - >窗口 - >首选项 - > maven - >安装 - >添加 - >代替安装主页添加路径到你安装maven的目录 - >完成 - >检查新增内容框 - >申请 - >确定。 now create new maven project but remember try with different group id and artifact id. 现在创建新的maven项目,但请记住尝试使用不同的组ID和工件ID。

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 我遇到了同样的问题我通过在eclipse中添加远程目录来解决它转到Window - > Preferences - > Maven - > Archetypes - >点击添加远程目录然后会在该粘贴中打开一个窗口
http://repo.maven.apache.org/maven2/archetype-catalog.xml in that catalog file then hit ok restart eclipse now all working fine 那个目录文件中的http://repo.maven.apache.org/maven2/archetype-catalog.xml然后点击确定重启eclipse现在一切正常

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

  1. Delete the maven-archetype-webapp:1.0 in the directory ~/.m2/repository/org/Apache/maven/archetypes 删除目录〜/ .m2 / repository / org / Apache / maven / archetypes中的maven-archetype-webapp:1.0

  2. 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/ 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

  3. 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的路径. 执行mvn install:install-file -DgroupId = org.apache.maven.archetypes -DartifactId = maven-archetype-quickstart -Dversion = 1.1 -Dpackaging = jar -Dfile =此处填maven-archetype-webapp-1.0的路径。

  4. try to establish a maven project of webapp to test whether the problem has solved. 尝试建立一个webapp的maven项目来测试问题是否已经解决。

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): 在Path变量(系统变量)中出现如下:

;D:\apache-maven-3.5.3\bin;

这对我有用: - 导航到windows-> preferences-> maven并检查“下载工件源”并单击“应用”。

No need to do all above lengthy steps. 无需执行所有上述冗长的步骤。

Simply delete c:\\Users\\.m2\\Repository\\org folder 只需删除c:\\ Users \\ .m2 \\ Repository \\ org文件夹即可

Maven will automatically downloads what it needs Maven将自动下载所需内容

I simple use below steps: 我简单地使用以下步骤:

Create Maven project -> check checkobox -> "Create a simple project (skip archetype selection)" 创建Maven项目 - >检查checkobox - >“创建一个简单的项目(跳过原型选择)”

It works for me 这个对我有用

我从这里下载了jar和pom,并将它们放在这里:

\.m2\repository\org\apache\maven\archetypes\maven-archetype-quickstart\1.1\

我也有同样的错误....我发现我的互联网连接已经关闭所以eclipse无法下载webapps原型的存储库,当我得到互联网连接时,我刚刚创建了maven项目与webapps archetypes和我的eclipse下载了存储库及其做...

This is 100% working: 这是100%工作:

  • Delete the .m2 folder which is present in your Desktop>User 删除桌面>用户中的.m2文件夹
  • connect your pc to the Internet 将您的电脑连接到互联网
  • Create your maven project again 再次创建您的maven项目

Thats it, hope it helps 多数民众赞成,希望它有所帮助

Try, It worked for = I just removed "archetypes" folder from below location尝试,它适用于 = 我刚刚从下面的位置删除了“archetypes”文件夹

C:\Users\Lenovo.m2\repository\org\apache\maven C:\Users\Lenovo.m2\repository\org\apache\maven

But you may change following for experiment - download latest binary zip of Maven, add to you C:\ drive and change following....但是您可以更改以下内容进行实验 - 下载 Maven 的最新二进制文件 zip,添加到您的 C:\ 驱动器并更改以下...。

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Change Proxy更改代理

 <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username></username>
          <password></password>
          <host>10.23.73.253</host>
          <port>8080</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>

The problem may also come from that you haven't set MAVEN_HOME environment variable. 问题还可能来自于您尚未设置MAVEN_HOME环境变量。 So the Maven embedded in Eclipse can't do its job to download the archetype.Check if that variable is set upfront. 因此,嵌入Eclipse中的Maven无法下载archetype.Check,如果该变量是预先设置的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法解析原型org.apache.maven.archetypes:maven-archetype-webapp - Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp 无法从任何配置的存储库中解析原型 org.apache.maven.archetypes:maven-archetype-quickstart:1.1 - Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.1 from any of the configured repositories 无法通过原型[org.apache.maven.archetypes:maven-archetype-webapp:1.0-&gt;]创建项目 - Unable to create project from archetype [org.apache.maven.archetypes:maven-archetype-webapp:1.0 -> ] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1 - org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1 Maven:无法执行目标 org.apache.maven.plugins:maven-resources-plugin:2.7:resources - Maven:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources 无法执行目标org.apache.maven.plugins:maven-jar-plugin:2.4:jar - Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.4:jar 无法执行目标org.apache.maven.plugins:maven-antrun-plugin - Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin 无法执行目标org.apache.maven.plugins:maven-clean-plugin:2.4.1 - Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1 Spring Boot 无法执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test - Spring Boot Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test Maven 无法执行目标 org.apache.maven.plugins:maven-clean-plugin:2.5:clean 无法删除 access_log - Maven Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean Failed to delete access_log
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM