Eclipse使用Maven创建Web时错误:Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webap

问题描述:

使用Eclipse自带的Maven插件创建Web项目时报错:

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:\Users\liujunguang\.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:\Users\liujunguang\.m2\repository)

错误如图:

解决方案:

在Eclipse Maven配置中添加新的Catalog配置:

也可以下载到本地,然后再添加,这样比较快,eclipse联网比较慢

     如图:
接下来在使用刚添加的catalog创建web工程这个时候就可以看到Eclipse联网下载了:


这个时候看一下是不是创建成功了

如果还是不能创建或者问题没有解决可以安装下面的方法:

1.删除maven已经下载的文件路径:.m2\repository\org\apache\maven

删除之后再试下,这时候如果看到有进度,只需要耐心等待就行了

2.Maven下载jar慢可以使用国内阿里镜像

具体配置文件(settings.xml)如下,放在.m2文件夹下,.m2一般位于用户目录下

[html]

  1. <settings xmlns=“http://maven.apache.org/SETTINGS/1.0.0”
  2.          xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
  3.          xsi:schemaLocation=”http://maven.apache.org/SETTINGS/1.0.0
  4.             http://maven.apache.org/xsd/settings-1.0.0.xsd”>
  5.     
  6.     <mirrors>
  7.         <mirror>
  8.           <id>aliyunid>
  9.           <name>aliyunname>
  10.           <url>http://maven.aliyun.com/nexus/content/groups/public/url>
  11.           <mirrorOf>centralmirrorOf>
  12.         mirror>
  13.     mirrors>
  14.     <profiles>
  15.         <profile>
  16.             <id>nexusid>
  17.             <repositories>
  18.                 <repository>
  19.                     <id>centralid>
  20.                     <url>http://repo.maven.apache.org/maven2url>
  21.                     <snapshots>
  22.                         <enabled>falseenabled>
  23.                     snapshots>
  24.                 repository>
  25.                 <repository>
  26.                     <id>ansj-repoid>
  27.                     <name>ansj Repositoryname>
  28.                     <url>http://maven.nlpcn.org/url>
  29.                     <snapshots>
  30.                         <enabled>falseenabled>
  31.                     snapshots>
  32.                 repository>
  33.             repositories>
  34.         profile>
  35.     profiles>
  36.     <activeProfiles>
  37.         <activeProfile>nexusactiveProfile>
  38.     activeProfiles>
  39. settings>
此条目发表在java相关分类目录,贴了标签。将固定链接加入收藏夹。