今天在intellij idea中创建maven的web工程时发现很慢很慢,基本上是卡在那半天没反应,于是试着在命令行创建。
使用如下命令:
mvn archetype:create -DgroupId=com.dexcoder -DartifactId=dexcoder-demo -DarchetypeArtifactId=maven-archetype-webapp
却报出如下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:create (default-cli) on project standalone-pom: Unable to parse configuration of mojo org.apache.ma
ven.plugins:maven-archetype-plugin:2.3:create for parameter #: Cannot create instance of interface org.apache.maven.artifact.repository.ArtifactRepository -> [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
一开始以为JDK版本太高缘故,因为Intellij idea还不支持最新的3.3.1版,故降到了3.1.1版使用,以为跟JDK版本不兼容,
降低jdk到1.6,错误依旧。
查询资料后发现,原来是我使用了create命令,将它换成generate后,错误不再出现
mvn archetype:generate -DgroupId=com.dexcoder -DartifactId=dexcoder-demo -DarchetypeArtifactId=maven-archetype-webapp
不知道这两个命令具体有啥区别,没深入研究,记得以前都是用create来创建的,难道是新的版本有改动?
在创建项目时,你会发现在如下两个点要等N长的时间,这个N长可能会以几十分钟来计算。
[INFO] Generating project in Interactive mode
[INFO] Generating project in Batch mode
加上这两个参数 -DinteractiveMode=false -DarchetypeCatalog=internal指定不从远程服务器上取catalog,可以让你快速的秒建项目,如果不加前者会让你输入一些信息回车确认。
mvn archetype:generate -DgroupId=com.dexcoder -DartifactId=dexcoder-demo -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false -DarchetypeCatalog=internal