第一次玩maven时,我只有一种感觉,”maven工程什么时候才能建立完成呀?“太慢了。
卡在某个地方,一动不动,一等就是十年。
皇天不负有心人,后来总算是找到解决办法了。
1.选好仓库
maven下载jar包的默认仓库是maven官方的仓库,外网下载jar包速度可想而知,所以我在settings.xml文件中修改了下载jar包的仓库(下载源)
这里用上了阿里的仓库
2.改动archetypeCatalog参数
解决上面的问题后,还要再等十年。
当我用maven archetype创建项目时,maven又上外网干了一件事, Searching for remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml,maven在寻找远程的archetypeCatalog信息,而它又在外网,不慢才怪。
后来我做了一件相当感人的事。
在第二个箭头所指的文本框中加入语句
-DarchetypeCatalog=internal
archetypeCatalog用来指定maven-archetype-plugin读取archetype-catalog.xml文件的位置。
参数-DarchetypeCatalog,可设的值有:
internal——maven-archetype-plugin内置的
local——计算机本地archetype-catalog.xml文件所在位置
remote——指向Maven中央仓库的archetypeCatalog
。它用来指定archetype-catalog.xml文件从哪里获取。
通过这两个改动,问题解决。