最近在学maven(maven能有效管理我们的jar包),在使用mvn命令创建maven项目的时候总是遇到Failed to execute goal org.apache.maven.plugin
错误和Generating project in Interactive mode
提示,也查阅过不少资料,在这里分享一下我的解决方案!
我之前是使用以下mvn命令来创建maven项目的
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
分析原因:可能是create已经过时了
解决方案:我们用官方文档上提供的命令archetype:generate
来代替create
即可
然后我就是用修改后的命令再次执行创建项目
mvn archetype:generate
发现程序一直卡在这个提示信息
[INFO] Generating project in Interactive mode
分析原因:这是在向远程服务器抓取catalog,而远程服务器设在了国外,所以在国内访问比较慢,这也是为什么会有国内镜像存在的原因
解决方案1(推荐):在命令后面加上一些参数 -DarchetypeCatalog=internal
方案2(不推荐):一个字,等!!我刚才试了下等上几分钟就能继续往下执行了~