首页 > 代码库 > Maven错误“Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create ”解决

Maven错误“Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create ”解决

用maven3新建一个项目时,输入的命令如下:

mvn archetype:create

出现错误如下:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (default-cli) on project standalone-pom: Unable to parse configuration of mojo org.apache.maven.plugins:maven-archetype-plugin:2.4:create for parameter #: Cannot create instance of interface org.apache.maven.artifact.repository.ArtifactRepository: org.apache.maven.artifact.repository.ArtifactRepository.<init>() -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[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 read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

可能存在的原因:比如Java HOME设置不正确,Maven HOME设置不正确,在Maven3使用Maven2的命令。

解决方法:

* JAVA_HOME没有设置或者设置有误、m2_home设置有误

* 删除/org/apache/maven/plugins/下的maven-archetype-plugin

* archetype:create命令已经过期,需要使用 archetype:generate 来进行代替(方案可行)

* maven-archetype-plugin 2.3版本的插件有问题,换其它版本进行创建(方案可行)

最终我直接升级了命令,问题解决:

mvn archetype:generate

 

Maven错误“Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create ”解决