maven很成熟,是開發java的必備利器,感覺我都離不開maven了,管理第三方庫真的很方便。
一、安裝
軟件安裝詳見點擊打開鏈接。eclipse最新版的j2ee本身自帶有maven插件,新建個maven項目即可,其中
選擇這個,然後繼續,新建工程後,工程會報錯,修改這個
但這個時候有個問題,因爲這個模板太老了,webmodel纔是2.3,連el表達式都用不了,這時候需要在項目源代碼中更改:
爲:
此時項目會有錯誤提示,但沒報錯,具體原因還要找下。
但此時項目缺少個規範的web.xml文件,可用如下的:
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
此爲示例,struts2聲明自己刪。
二、maven入門
入門最好的讀物還是官方的,在官方網址中左側有個usercent,裏面有些很好的入門資料,官方網址在點擊打開鏈接
三、搜索第三方庫
第三方庫搜索的地址是:http://search.maven.org/
四、pom項目變eclipse項目
cmd到項目路徑,執行mvn eclipse:eclipse
然後eclipse導入項目即可