1.創(chuàng)建Maven項(xiàng)目:
點(diǎn)擊“File”菜單,或者通過工具欄的“New”創(chuàng)建Project,如下圖所示:
選擇Maven-》Maven Project,彈出向?qū)υ捒?,如下圖所示:
選中Create a simple project……復(fù)選框,其它的設(shè)置不變,并點(diǎn)擊Next,輸入maven項(xiàng)目必須的信息(groupId,artifactid,version),如下圖所示:
這里需要選擇Packaging,web項(xiàng)目一般選擇war即可。點(diǎn)擊Finish,完成項(xiàng)目創(chuàng)建,下圖為創(chuàng)建的項(xiàng)目結(jié)構(gòu)(項(xiàng)目名稱為:sample-webapp):
2.配置web項(xiàng)目:
右鍵點(diǎn)擊sample-webapp項(xiàng)目,依次點(diǎn)擊Properties-》Project Facets-》Convert to faceted form… ,如下圖所示:
勾選Dynamic Web Module,并選擇版本(這里使用2.5,由于3.0版本需要tomcat7),如下圖所示:
點(diǎn)擊OK,此時(shí),項(xiàng)目結(jié)構(gòu)樹增加了WebContent文件夾,如下圖所示:
將WebContent下的WEB-INF、META-INF文件夾copy到src/main/webapp目錄下,并且刪除WebContent目錄,完成之后,如下圖所示:
右鍵點(diǎn)擊sample-webapp項(xiàng)目,依次點(diǎn)擊Properties-》Deployment Assembly,如下圖所示:
此時(shí),通過Remove按鈕刪除/src/test/java、/src/test/resources、/WebContent,并且通過Add添加webapp與maven依賴,如下圖所示:
首先Add-》Folder,選擇webapp目錄并Finish,再選擇Java Build Path Entries-》Maven Dependencies
完成之后,如下圖所示:
3.部署web項(xiàng)目:
添加tomcat server,并部署web項(xiàng)目,這里不描述,與非maven項(xiàng)目基本相同。
點(diǎn)擊“File”菜單,或者通過工具欄的“New”創(chuàng)建Project,如下圖所示:

選擇Maven-》Maven Project,彈出向?qū)υ捒?,如下圖所示:

選中Create a simple project……復(fù)選框,其它的設(shè)置不變,并點(diǎn)擊Next,輸入maven項(xiàng)目必須的信息(groupId,artifactid,version),如下圖所示:

這里需要選擇Packaging,web項(xiàng)目一般選擇war即可。點(diǎn)擊Finish,完成項(xiàng)目創(chuàng)建,下圖為創(chuàng)建的項(xiàng)目結(jié)構(gòu)(項(xiàng)目名稱為:sample-webapp):

2.配置web項(xiàng)目:
右鍵點(diǎn)擊sample-webapp項(xiàng)目,依次點(diǎn)擊Properties-》Project Facets-》Convert to faceted form… ,如下圖所示:

勾選Dynamic Web Module,并選擇版本(這里使用2.5,由于3.0版本需要tomcat7),如下圖所示:

點(diǎn)擊OK,此時(shí),項(xiàng)目結(jié)構(gòu)樹增加了WebContent文件夾,如下圖所示:

將WebContent下的WEB-INF、META-INF文件夾copy到src/main/webapp目錄下,并且刪除WebContent目錄,完成之后,如下圖所示:

右鍵點(diǎn)擊sample-webapp項(xiàng)目,依次點(diǎn)擊Properties-》Deployment Assembly,如下圖所示:

此時(shí),通過Remove按鈕刪除/src/test/java、/src/test/resources、/WebContent,并且通過Add添加webapp與maven依賴,如下圖所示:




首先Add-》Folder,選擇webapp目錄并Finish,再選擇Java Build Path Entries-》Maven Dependencies
完成之后,如下圖所示:

3.部署web項(xiàng)目:
添加tomcat server,并部署web項(xiàng)目,這里不描述,與非maven項(xiàng)目基本相同。










