windows下安装maven后运行:mvn help:system报错

  其实在Maven安装后执行mvn help:system命令报错,且在这个错误未解决前,在使用Eclipse构建Maven项目时,也报Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp错,如下所示:

        当然,其间,用maven命令创建maven工程时,有如下提示:

Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
"[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.5:Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5"

        从网上看到有些原因分析,总结如下:

  1)所用网络不能访问maven.apache.org

  2)代理服务器没有配置,或配置不正确

  如果你所在的公司基于安全因素考虑,要求你使用通过安全认证的代理访问因特网,这时就需要为Maven配置HTTP代理。

  修改D:\Maven和D:\software\maven\apache-maven-3.5.3\conf下的settings.xml文件(特别注意,这两处的settings.xml都需要修改),增加代理配置如下:


  其中:

        active:表示激活该代理;

        protocol:表示代理的协议,在这里是http;

        username:代理服务器用户名;

        password:代理服务器密码;

        host:代理服务器地址;

        port:代理服务器端口;

        nonProxyHosts:不使用代理服务器访问的主机地址。

       修改后,在cmd窗口中执行mvn help:system命令正常,并且在Eclipse中创建Maven项目时,也不报Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp错,项目创建正常。

        3)在Eclipse Maven配置中添加新的Catalog配置

        配置:http://repo1.maven.org/maven2/archetype-catalog.xml,也可以下载到本地,然后再添加,这样比较快,eclipse联网比较慢,如下所示:


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


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


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

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

  a.删除maven已经下载的文件路径:.m2\repository\org\apache\maven,在我这里是D:\Maven\repo\org\apache\maven。删除之后再试下,这时候如果看到有进度,只需要耐心等待就行了。

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

        具体配置文件(settings.xml)如下,放在.m2文件夹下,.m2一般位于用户目录下。当然,在我这里需修改D:\Maven\settings.xml和D:\software\maven\apache-maven-3.5.3\conf\settings.xml。

<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>

 

参考文章:http://love2157dream.iteye.com/blog/2100337

http://blog.csdn.net/yudilan6/article/details/51996673

https://www.cnblogs.com/rever/p/7076596.html

http://blog.csdn.net/afgasdg/article/details/12757433

http://blog.csdn.net/nphyez/article/details/34438927

猜你喜欢

转载自bijian1013.iteye.com/blog/2413257