尝试创建简单的maven项目时插件不可用

时间:2012-01-20 16:55:57

标签: maven maven-3

当我尝试运行这个maven目标时 -

mvn archetype:generate -DgroupId = com.mycompany.app -DartifactId = my-app -DarchetypeArtifactId = maven-archetype-quickstart -DinteractiveMode = false

(摘自http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

我收到此错误 -

INFO] Scanning for projects...
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
lean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-clean-plugin:2.4.1: Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 o
 one of its dependencies could not be resolved: Failed to read artifact descrip
or for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
nstall-plugin/2.3.1/maven-install-plugin-2.3.1.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-install-plugin:2.3.1: Plugin org.apache.maven.plugins:maven-install-plugin:2.3
1 or one of its dependencies could not be resolved: Failed to read artifact des
riptor for org.apache.maven.plugins:maven-install-plugin:jar:2.3.1
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
eploy-plugin/2.7/maven-deploy-plugin-2.7.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or
ne of its dependencies could not be resolved: Failed to read artifact descripto
 for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
ite-plugin/3.0/maven-site-plugin-3.0.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-site-plugin:3.0: Plugin org.apache.maven.plugins:maven-site-plugin:3.0 or one
f its dependencies could not be resolved: Failed to read artifact descriptor fo
 org.apache.maven.plugins:maven-site-plugin:jar:3.0
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
ntrun-plugin/1.3/maven-antrun-plugin-1.3.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or
ne of its dependencies could not be resolved: Failed to read artifact descripto
 for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
ssembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plu
in:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read
rtifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-b
ta-5
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
ependency-plugin/2.1/maven-dependency-plugin-2.1.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-dependency-plugin:2.1: Plugin org.apache.maven.plugins:maven-dependency-plugin
2.1 or one of its dependencies could not be resolved: Failed to read artifact d
scriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.1
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
elease-plugin/2.0/maven-release-plugin-2.0.pom
WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
-release-plugin:2.0: Plugin org.apache.maven.plugins:maven-release-plugin:2.0 o
 one of its dependencies could not be resolved: Failed to read artifact descrip
or for org.apache.maven.plugins:maven-release-plugin:jar:2.0
ownloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadat
.xml
ownloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
etadata.xml
WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xm
 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org
WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/
o central (http://repo.maven.apache.org/maven2): repo.maven.apache.org
WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from h
tp://repo.maven.apache.org/maven2 was cached in the local repository, resolutio
 will not be reattempted until the update interval of central has elapsed or up
ates are forced. Original error: Could not transfer metadata org.apache.maven.p
ugins/maven-metadata.xml from/to central (http://repo.maven.apache.org/maven2):
repo.maven.apache.org
WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from http://r
po.maven.apache.org/maven2 was cached in the local repository, resolution will
ot be reattempted until the update interval of central has elapsed or updates a
e forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-m
tadata.xml from/to central (http://repo.maven.apache.org/maven2): repo.maven.ap
che.org
INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
INFO] ------------------------------------------------------------------------
INFO] Total time: 0.706s
INFO] Finished at: Fri Jan 20 16:49:34 GMT 2012
INFO] Final Memory: 2M/15M
INFO] ------------------------------------------------------------------------
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
epositories [local (C:\.m2\repository), central (http://repo.mave
.apache.org/maven2)] -> [Help 1]
ERROR]
ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
h.
ERROR] Re-run Maven using the -X switch to enable full debug logging.

这个插件可用吗?

4 个答案:

答案 0 :(得分:6)

您是代理还是防火墙?听起来它无法看到中央回购。

答案 1 :(得分:0)

以下命令在我的电脑上正常工作:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

这听起来确实像HTTP代理问题......

答案 2 :(得分:0)

修改你的setting.xml,如下所述。

<?xml version="1.0" encoding="UTF-8"?>

<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">
  <localRepository>C:/Documents and Settings/1401044/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline>false</offline>
</settings>

答案 3 :(得分:0)

您可以在maven的 settings.xml 文件中添加代理,如下所示:

<proxies>
    <proxy>
        <active>true</active>
        <protocol>http</protocol>
        <username>username</username>
        <password>password</password>
        <host>proxy.servername</host>
        <port>8080</port>
    </proxy>
</proxies>