第一步:
创建maven web工程
第二步:
继承parent
修改pom.xml文件如下
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.bling.maven</groupId>
<artifactId>web</artifactId>
<packaging>war</packaging>
<name>web Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>cn.bling.maven</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-RELEASE</version>
<relativePath>../Parent/pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>cn.bling.maven</groupId>
<artifactId>MakeFriends</artifactId>
</dependency>
</dependencies>
</project>
第三步:
建立测试jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="cn.bling.maven.MakeFriends.*"%>
<%
MakeFriends makeFriends=new MakeFriends();
out.println(makeFriends.makeFriends("wanglipeng"));
%>
第四步:
自动部署到tomcat下面
<build>
<finalName>web</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.3</version>
<configuration>
<container>
<containerId>tomcat5x</containerId>
<home>D:/Program Files/Apache Software Foundation/Tomcat 7.0</home>
</container>
<configuration>
<type>existing</type>
<home>D:/Program Files/Apache Software Foundation/Tomcat 7.0</home>
</configuration>
</configuration>
<executions>
<execution>
<id>cargo-run</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
第五步:
模块聚合
修改parent.pom