Eclipse使用Maven外掛建立Web專案時出錯 Could not resolve archetype org a
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
問題描述:
在Eclipse下,使用Maven外掛建立Web專案時出錯,錯誤提示如下:
錯誤資訊:
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): Remote host closed connection during handshake
Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): Remote host closed connection during handshake
解決方案:
在Eclipse中開啟“Preferences”--偏好設定視窗,在左側列表中找到“Maven”的配置項,在展開列表之後選擇“Archetypes”;
點選右側的“Add Remote Catalog”按鈕,在彈出的視窗中,在“Catalog File”輸入框中輸入:
在“Description”輸入框中輸入“maven remote catalog”(名字個人隨意),點選“OK”按鈕完成新增;繼續點選“OK”按鈕儲存Maven設定。http://repo1.maven.org/maven2/archetype-catalog.xml
在設定完畢之後,重新新建Maven專案,在彈出的視窗中,在“Catalog:”下拉框中選擇剛才新建的“maven remote catalog”,然後找到“Group Id”為“org.apache.maven.archetypes”,“Artifact Id”為“maven-archetype-webapp”的選項(在這裡列表選項過多,可以在“Filter”輸入框中輸入相應的資訊進行查詢),點選“Next”按鈕:
輸入專案的相關資訊,點選“Finish”按鈕,即可完成Web專案的新建工作:
在點選完“Finish”按鈕之後,這時候發現Eclipse就開始從遠端的庫中下載構建Web專案所需要的相關東西了:
最後在Eclipse專案列表中發現有“Framework”專案,並在Tomcat下成功釋出並可以訪問,表明使用Eclipse的Maven外掛新建Web專案成功了。