Posted on 2008-02-21 17:39
迟来的兵 阅读(494)
评论(2) 编辑 收藏 所属分类:
Maven
当使用mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app来创建一个新项目时,有时候会出现以下错误:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO]
----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:create] (aggregator-style)
[INFO]
----------------------------------------------------------------------------
。。。。。。。
[INFO] Velocimacro : initialization complete.
[INFO] Velocity successfully started.
[INFO] [archetype:create]
[INFO] Defaulting package to group ID: com.mycompany.app
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
GroupId: org.apache.maven.archetypes
ArtifactId: maven-archetype-quickstart
Version: RELEASE
Reason: Unable to determine the release version
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.apache.maven.archetypes
-DartifactId=maven-arch
etype-quickstart \
-Dversion=RELEASE -Dpackaging=jar -Dfile=/path/to/file
org.apache.maven.archetypes:maven-archetype-quickstart:jar:RELEASE
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Apr 17 07:08:50 MDT 2007
[INFO] Final Memory: 4M/8M
[INFO]
------------------------------------------------------------------------
请注意红色部分为错误产生的根本原因, 由于maven还处于开发过程中,开发方极有可能已经更新某个plug-in的版本,但本地plug-in 的metadata没有版本的信息或者没有最新版本的信息,致使maven无法下载正确的版本。同时请注意蓝色部分,这是提示的解决办法。具体步骤如下:
1.打开网址:http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/
2.选择最新版本并且下载最新的“maven-archetype-quickstart-1.0-alpha-4.jar ”文件
3.安装这个archetype到maven本地仓库。使用命令如下:mvn install:install-file -DgroupId=org.apache.maven.archtypes -Dar
tifactId=maven-archetype-quickstart -Dversion=1.0-alpha-4 -Dpackaging=jar -Dfile=c:\7000\maven\maven-archetype-quickstart-1.0-alpha-4.jar。注意-Dfile是刚下载的文件的路径。
现在在cmd中执行mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app就可以创建新项目了。