1、在eclipse中安裝插件m2eclipse
(如果eclipse中沒有插件的話,需要手動安裝,如果eclipse中已經存在這個插件,則不需要安裝)
在Eclipse中的Help菜單下點擊Instance NewSoftWare,會彈出窗口,點擊add,輸入
Name:m2e
Location:http://download.eclipse.org/technology/m2e/releases
按照步驟安裝插件即可
2、下載maven並配置
進入maven官網的下載頁面:http://maven.apache.org/download.cgi下載maven項目
進入maven根目錄下的conf子目錄,打開settings.xml進行配置修改
(1)修改默認的本地倉庫的位置<localRepository>d:/.m2/repository</localRepository> #將默認的本地倉庫的位置修改到d:/.m2/repository
(2)修改默認的中央倉庫鏡像
<mirrors> <mirror> <id>aliyun</id> <name>aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <profiles> <profile> <id>nexus</id> <repositories> <repository> <id>central</id> <url>http://repo.maven.apache.org/maven2</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>ansj-repo</id> <name>ansj Repository</name> <url>http://maven.nlpcn.org/</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles>
保存所做的修改,並將這個settings.xml文件復制到d:/.m2目錄下
3、設置插件關聯的maven程序
在Eclipse中的window菜單下點擊Preferences,找到maven:
展開maven節點,選擇Installations子節點,點擊add按鈕,選擇你要添加的maven項目的根目錄
4、設置自己的本地倉庫
打開maven的子節點User Setting,這里修改為自定義倉庫位置下的setting.xml文件,具體操作點擊Browse…
5、新建maven項目
選擇webapp項目
maven項目就新建完成了。
本文參考: