Maven 3:无法执行目标org.apache.maven.plugins:maven-archetype-plugin:2.2:generate - java

我正在尝试使用来测试 maven

mvn archetype:generate -DgroupId=org.sonatype.mavenbook -DartifactId=quickstart -Dversion=1.0-SNAPSHOT -DpackageName=org.sonatype.mavenbook -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.0 -DinteractiveMode=false

几分钟后,系统显示以下内容:

Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-catalog/2.2/archetype-catalog-2.2.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-catalog/2.2/archetype-catalog-2.2.pom (2 KB at 4.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-models/2.2/archetype-models-2.2.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-models/2.2/archetype-models-2.2.pom (3 KB at 5.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.8/plexus-utils-1.5.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.8/plexus-utils-1.5.8.pom (8 KB at 17.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/2.0.2/plexus-2.0.2.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/ant/ant-parent/1.8.1/ant-parent-1.8.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30:36.874s
[INFO] Finished at: Tue Feb 07 15:59:39 BRST 2012
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate failed: Plugin org.apache.maven.plugins:maven-archetype-plugin:2.2 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-archetype-plugin:jar:2.2 (): Failed to read artifact descriptor for org.codehaus.plexus:plexus-utils:jar:1.5.8: Could not transfer artifact org.codehaus.plexus:plexus:pom:2.0.2 from/to central (http://repo.maven.apache.org/maven2): Read timed out -> [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/PluginResolutionException

我怎样才能解决这个问题?提前致谢!

参考方案

使用Idea IDE创建项目时,我也遇到了相同的问题。使用以下方法,您可以创建独立应用程序或Web应用程序,而不会出现任何错误。

转到终端。输入以下提到的命令并执行。

对于Web应用程序:
mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
对于独立应用程序:
mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
这将通过下载相关的jars等来创建项目结构。完成后,将创建项目结构。打开一个IDE并将其定向到创建的Project的Pom.xml文件。

Maven:将本地依赖项添加到jar - java

我有一个依赖 <dependency> <groupId>de.matthiasmann</groupId> <artifactId>twl</artifactId> <version>1.0.0</version> <scope>system</scope…

Maven:从jar工件中排除生成的源 - java

Duplicate,但没有答案,无法评论背景信息:我有一个模块,该模块使用xmlbeans-maven-plugin从xsd生成Java源文件并将其编译到其自己的jar中。这可以正常工作,并使用Java源代码创建一个module1 / target / generated-sources文件夹。该模块已构建,但生成的源包含在jar中,这是不必要的,因为xml…

是否存在可以透明地构建请求的但缺少本地工件的Maven存储库? - java

我们正在美化现有的开发流程,并且发现,如果我们新的内部Maven工件存储库可以透明地触发构建缺失的内部工件,那么这将使后勤工作变得更加简单。换句话说,开发人员需要在发行版X.Y.Z中处理依赖于我们自己的组件B的组件A,并且由于某种原因该资源在存储库中不存在。但是,我们知道在给定所需的发行版号的情况下,确切地如何构建B的发行版,并且拥有一个可脚本化的过程来检出…

在大型项目上使用声纳 - java

我正在做一个相当大的项目(围绕Maven 550模块)。现在,我想知道如何在CI级别的大型项目上运行声纳(为此我们使用Jenkins)如果我们从父pom文件夹中运行mvn sonar:sonar,它会运行约1小时,然后即使在内存容量显着增加的情况下,也会在OutOfMemory上失败(〜16GB)因此,我们研究了运行声纳的其他策略。当前最吸引人的想法是:在生…

如何列出JAR的依赖项 - java

有没有一种工具可以列出包含JAR中引用的(第三方)类的第三方“软件包”?假设它将从JAR文件定义中识别出什么是“home”包,并且它将打印出JAR中所引用的第三方类的完全合格名称(直到第3级)的列表。org.apache.commons org.apache.maven javax.servlet.jsp org.eclipse.persistence or…