C:\Users\tx>mvn archetype:generate -DgroupId=com.alibaba.webx -DartifactId=tutorial3 -Dversion=1.0-SNAPSHOT -Dp ackage=com.alibaba.webx.tutorial3 -DarchetypeArtifactId=archetype-simple-webx3 -DarchetypeGroupId=com.alibaba.citrus.sam ple -DinteractiveMode=false [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error building POM (may not be this project's POM). Project ID: org.apache.maven.plugins:maven-archetype-plugin Reason: Error getting POM for 'org.apache.maven.plugins:maven-archetype-plugin' from the repository: Failed to resolve a rtifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata. org.apache.maven.plugins:maven-archetype-plugin:pom:2.3-SNAPSHOT from the specified remote repositories: central (http://repo1.maven.org/maven2) for project org.apache.maven.plugins:maven-archetype-plugin [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: < 1 second [INFO] Finished at: Fri Nov 09 11:28:07 CST 2012 [INFO] Final Memory: 2M/1016M [INFO] ------------------------------------------------------------------------
mvn archtype:generate 自行会到本地仓库查找archtype插件,查看本地D:\work\repository\org\apache\maven\plugins\maven-archetype-plugin下的插件版本为2.2,而maven-metadata-central.xml是2.3-SNAPSHOT并且仓库中没有这个版本的jar包,所以出错。
<?xml version="1.0" encoding="UTF-8"?> <metadata> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-archetype-plugin</artifactId> <versioning> <latest>2.3-SNAPSHOT</latest> <release>2.2</release> <versions> <version>1.0-alpha-3</version> <version>1.0-alpha-4</version> <version>1.0-alpha-7</version> <version>2.0-alpha-1</version> <version>2.0-alpha-2</version> <version>2.0-alpha-3</version> <version>2.0-alpha-4</version> <version>2.0-alpha-4-alipay</version> <version>2.0-alpha-4.alipay</version> <version>2.0-alpha-4-alipay-bugfix1</version> <version>2.0-alpha-4-alipay-bugfix2</version> <version>2.0-alpha-5</version> <version>2.0-alpha-6-SNAPSHOT</version> <version>2.0</version> <version>2.1</version> <version>2.2</version> <version>2.3-SNAPSHOT</version> </versions> <lastUpdated>20120228230945</lastUpdated> </versioning> </metadata>
解决方法:
把maven-metadata-central.xml文件中的2.3-SNAPSHOT去掉,选择2.2版本。