第一步创建maven web工程。
<role rolename="manager"/>
<user username="admin" password="admin" roles="manager"/>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:/maven/repository</localRepository>
<servers>
<server>
<id>myserver</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
第二步,设置tomcat-users.xml。
<tomcat-users>
</tomcat-users>
第三步,配置maven的settings.xml。
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
</settings>
第四步,pom.xml中添加
tomcat-maven-plugin插件。
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<configuration>
<url>http://127.0.0.1:8080/manager/html</url>
<server>myserver</server>
<URIEncoding>UTF-8</URIEncoding>
</configuration>
</plugin>
</plugins>
第五步,运行命令tomcat:run。
第六步,验证一下。
另外,还可以加入maven-antrun-plugin这样的插件,可以编写ant脚本。
<!-- ant插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy</id>
<phase>compile</phase>
<configuration>
<target>
<!-- ant script here begin -->
<copy todir="E:/数据报表测试20120509/ReportModuleConfig"
overwrite="true">
<fileset dir="${basedir}/ui/" />
</copy>
<!-- <copy todir="${basedir}/target/classes/com/gw/commodity/mapper"
overwrite="true"> <fileset dir="${basedir}/src/main/java/com/gw/commodity/mapper"
/> </copy> -->
<!-- ant script here end -->
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>