原因
IDEA根據maven archetype的本質,其實是執行mvn archetype:generate命令,該命令執行時,需要指定一個archetype-catalog.xml文件。
該命令的參數-DarchetypeCatalog,可選值為:remote,internal ,local等,用來指定archetype-catalog.xml文件從哪里獲取。
默認為remote,即從 http://repo1.maven.org/maven2/archetype-catalog.xml路徑下載archetype-catalog.xml文件。
http://repo1.maven.org/maven2/archetype-catalog.xml 文件約為3-4M,下載速度很慢,導致創建過程卡住。
解決方法
1.在下面界面添加一個屬性,archetypeCatalog = internal
方法二
在maven的VM Options加上-DarchetypeCatalog=internal參數,如下:
方法3: 用local (推薦這種方法 完美)
1.由於默認情況下,根據archetype創建maven項目會從網絡下載catalog文件,導致創建maven項目緩慢
Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml
2.解決辦法可以設置使用本地catalog文件,在IDEA中設置archetype的使用方式為local;
-DarchetypeCatalog=local
直接先把 文件用搜狗瀏覽器或其它下載工具下載下來。
下載后放到哪里呢,這里與本地倉庫的位置有關,假如本地倉庫是maven默認的,並沒有修改 那么就需要放到 C:\Users\del-berlin\.m2\repository\org\apache\maven\archetype\archetype-catalog\2.4\下 ,本地倉庫的默認位置:Default: ${user.home}/.m2/repository