1.在eclipse的marketplace中下载maven插件.安装完成后,在需要maven管理的工程中右键选:enable dependency management.
2.通过pom.xml加入依赖包.
3.在pom中加入maven-war-plugin插件,并进行配置:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webXml>${basedir}/WebContent/WEB-INF/web.xml</webXml>
<outputDirectory>${project.build.directory}</outputDirectory>
<warName>statistic</warName>
<warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
<webappDirectory>${project.build.directory}/statistic</webappDirectory>
<archiveClasses>true</archiveClasses>
<webResources>
<resource>
<directory>target/classes</directory>
<targetPath>WEB-INF/classes</targetPath>
<includes>
<include>**/sample.lic</include>
<include>**/db.properties</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
4.右键工程run as -> maven package 即可生成war包.
注:由于用maven工具管理包之后.web/lib下将没有原来的包,开发时如果要部署到tomcat进行运行,需要右键工程properties -> deployment assembly, 点击add, 选择java build path entries, 点击next, 选择maven dependencies, 点击finish完成后,可看到maven依赖包被指定部署到web-inf/lib中.
附:
eclipse 的indigo版本maven插件update地址:
http://m2eclipse.sonatype.org/sites/m2e
用eclipse的Maven插件管理工程
猜你喜欢
转载自qingwei201314.iteye.com/blog/1115090
今日推荐
周排行