您的位置:首页 > 运维架构 > Apache

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

2018-11-07 11:09 302 查看

使用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)

解决方案:

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

如图:

接下来在使用刚添加的catalog创建web工程

这个时候就可以看到Eclipse联网下载了:

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

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

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


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

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

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
            http://maven.apache.org/xsd/settings-1.0.0.xsd">
    
    <!-- 这个是配置阿里Maven镜像 -->
    <mirrors>
        <mirror>
          <id>aliyun</id>
          <name>aliyun</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
    
    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://repo.maven.apache.org/maven2</url>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>ansj-repo</id>
                    <name>ansj Repository</name>
                    <url>http://maven.nlpcn.org/</url>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
 
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

如果此时还不成功,可以查看下当前maven创建webapp的jar包是否存在,找到自己的response,我的目录是在

C:\Users\windowsusr\.m2\repository\org\apache\maven\archetypes\maven-archetype-webapp\1.3下

文件夹里发现下载jar包失败,解决方案如下:

去maven仓库下载:https://mvnrepository.com/search?q=maven-archetype-webapp-1.3,如下图

点击view进去后下载必要的文件到本地私有仓库里

然后重新创建一遍maven springmvc项目后,成功!!

(adsbygoogle = window.adsbygoogle || []).push({});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐