meven dos下构建项目失败

来源:互联网 发布:程序员的工作环境 编辑:程序博客网 时间:2024/06/16 13:20

初次学习使用meven,在官网上下载安装成功后,构建hello world级的项目,总是失败,说找不到插件archetype。

错误信息:

[ERROR] No plugin found for prefix ‘archetype’ in the current project and in the
plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the
repositories [local (C:\Users\kang.m2\repository), central (https://repo.maven.
apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundF
orPrefixException

因为构建的项目很简单,所有很容易猜到是网络的原因。
解决的方法有两种:一、设置一个稳定的代理,二、修改远程仓库

第一种方法我没找到合适的代理,这里我就先说一下第二种:
找到meven安装目录下的conf/settings.xml文件,找到mirrors标签,为它添加下面内容:

    <mirror>      <id>alimaven</id>      <name>aliyun maven</name>      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>      <mirrorOf>central</mirrorOf>            </mirror>

这个是来自阿里的meven仓库,速度快的飞起。

第一种方法也简单说下
修改安装用户下的.m2/settings.xml文件,如果没找到,那么把meven的安装目录下的conf/settings.xml复制过去,然后编辑该文件的proxies部分,如果被注释了打开注释

  <proxies>    <!-- proxy     | Specification for one proxy, to be used in connecting to the network.     | -->    <proxy>      <id>optional</id> <!-- 代理名称 -->      <active>true</active>  <!-- 代理是否激活 -->      <protocol>http</protocol> <!-- 代理使用协议 -->      <username>proxyuser</username> <!-- 如果代理需要验证配置用户名和密码,否则可以删除 -->      <password>proxypass</password>      <host>proxy.host.net</host> <!-- 代理主机 -->      <port>80</port> <!-- 代理端口号 -->      <nonProxyHosts>local.net|some.host.com</nonProxyHosts><!--某些地址不需要经过代理服务器,多个地址之间用|分隔,支持通配符,比如172.156.*-->    </proxy>  </proxies>
原创粉丝点击