如題目所述,有很多解決這個問題的文章,但可能有點問題,這裏再總結一下。
Idea 界面在 Generating project in Batch mode 卡住的原因是:網絡不好的話,下載archetype-catalog.xml 太慢(地址:http://repo.maven.apache.org/maven2/archetype-catalog.xml)。
解決辦法:
1)可先下載好archetype-catalog.xml (6.32M),放到:
C:\Users\Administrator\.m2\repository\org\apache\maven\archetype\archetype-catalog\3.0.1
2)再設置如下VM Options: -DarchetypeCatalog=internal。注意是File 菜單的Other settings - Default settings. 在File - Settings 裏也有一樣的設置項,但好像沒用。
在上面兩步完成之前,Maven 創建記錄:“Using the one from [org.apache.cocoon:cocoon-22-archetype-webapp:1.0.0] found in catalog remote.”; 之後的記錄:"Falling back to central repository."。遠程下載的確要比本地調用多幾倍的時間。
另外IDEA 界面右下角會出現一個baloon, “Maven - Import changes",點擊之後main 下面的resourse 和webapp 文件夾纔會變成如下圖的顏色(Java 文件夾可手動創建,再右鍵Mark directory as - Rources Root )。