eclipse插件maven的使用,web打包成WAR,tomcat下直接运行

首先下载maven  其下载地址为:http://maven.apache.org/download.html   下载apache-maven-3.0.3-bin.zip

环境变量配置为  变量名m2   值为%M2_HOME%\bin   变量名为M2_HOME   值为C:\Program Files\apache-maven-3.0.3    在变量名path里添加  %M2%

然后启动eclipse ,在help 里选择install new software 在里面 在URL上输入 http://m2eclipse.sonatype.org/sites/m2e/ 

然后重新启动eclipse

点击new project   选择others   点marven  在里面选择marven project ,如果创建WEB项目就选择 marven-archetype-webapp   接着后面输入 ,自己看着办。

创建项目后 ,在项目的web.xml中加入如下

代码<welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

点run as 中的marven package 。 将项目生成war文件,然后将该文件拷贝到tomcat的webapps文件下,在tomcat的bin目录下点击startup.dos文件启动tomcat,然后在浏览器上输入http://localhost:8080/项目名/

然后页面会显示Hello Word!

猜你喜欢

转载自xiangjinqi.iteye.com/blog/1071859
今日推荐