Maven开发总结

来源:互联网 发布:网络环境 编辑:程序博客网 时间:2024/06/06 14:25

          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导入项目即可
          

 

0 0