idea创建maven工程的时候经常半天还在下载!特意百度了一下 。基本上说是下载一个xml文件到本地。工具里面指定-DarchetypeCatalog=internal
-DarchetypeCatalog=local
2016年11月27日00:32:55
亲测 新建maven项目时添加archetypeCatalog = internal 有效
2017年3月9日10:18:063
创建maven项目的时候总是失败提示
乱码�� Dmaven.multiModuleProjectDirectory=$M2_HOME
新建maven项目时添加archetypeCatalog = internal,去掉设置中的这个参数设置后反而成功了如下图
之前一直在执行中,目录结构也没出来。添加这个参数后成功。新装的系统用户目录下没有发现.m2的目录。
启动参数实践证明正确步骤应该如此
下载xml文件 http://repo1.maven.org/maven2/archetype-catalog.xml
我是连的vpn下载的 基本上几秒钟就下好了
百度云下载连接
下载的文件放在用户名下一个 .m2的文件夹中 如下图
设置启动参数 参考此篇
补充内容 文中提到的, 关键步骤!设置默认启动的时候 应该是
注意右上角的灰字:for default project,而不是for current project
file -> other settings ->default settings
设置默认参数 图文教程 参考这篇
构建maven项目
构建过程中出现如下错误
"C:\Program Files\Java\jdk1.7.0_79\bin\java" -DarchetypeCatalog=internal "-Dmaven.home=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.1\plugins\maven\lib\maven3\bin\m2.conf" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.1.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar" org.codehaus.classworlds.Launcher -Didea.version=2016.1.1 -s D:\develop_software\apache-maven-3.3.9\conf\settings.xml -DinteractiveMode=false -DgroupId=Mv -DartifactId=com.maobo.mv -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=internal org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] Archetype repository not defined. Using the one from [org.apache.maven.archetypes:maven-archetype-webapp:1.0] found in catalog internal
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.349s
[INFO] Finished at: Sun Oct 16 22:20:05 CST 2016
[INFO] Final Memory: 10M/120M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.apache.maven.archetypes:maven-archetype-webapp:internal) -> [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/MojoFailureException
[ERROR] Maven execution terminated abnormally (exit code 1)
根据提示
Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: The desired archetype does not exist
说找不到。去目录下找确实也没有。索性删除了整个maven文件夹
参考此篇
C:\Users\Maobo\.m2\repository\org\apache
删除了这个目录下的maven文件夹。关掉所有idea窗口后重新开启再新建maven项目就可以了
PS:新建maven项目的时候 并没有改任何参数。那个修改为internal的也没有改
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.047s
[INFO] Finished at: Sun Oct 16 22:47:20 CST 2016
[INFO] Final Memory: 10M/120M
[INFO] ------------------------------------------------------------------------
[INFO] Maven execution finished
再加个tomcat后启动
启动tomcat时有个错
警告: The APR based Apache Tomcat Native library failed to load. The error reported was [D:\develop_software\apache-tomcat-7.0.69\bin\tcnative-1.dll: Can't load IA 64-bit .dll on a AMD 64-bit platform]
java.lang.UnsatisfiedLinkError: D:\develop_software\apache-tomcat-7.0.69\bin\tcnative-1.dll: Can't load IA 64-bit .dll on a AMD 64-bit platform
没有去管它。可能要去下个64位的tomcat
最后一番折腾终于看到hello world了!
另外 无意间发现阿里云的镜像下载jar包还挺快的。
maven配置文件中可以改成
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
| -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>