案例使用的是servlet的一个简单的“hello maven!”.下面来介绍配置步骤
1.在pom.xml文件中配置tomcat插件,配置好的pom.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--本项目坐标信息-->
<groupId>edu.hohai</groupId>
<artifactId>helloWorld_01</artifactId>
<version>1.0-SNAPSHOT</version>
<!--打包成war-->
<packaging>war</packaging>
<!--依赖jar信息-->
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!--配置Tomcat用于debug-->
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<!--<url>http://localhost:8080/data</url>-->
<!--<server>tomcat7-local</server>-->
<!--项目名称根路径-->
<path>/helloWorld_01</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
2.配置tomcat运行/调试环境
3.在项目中打断点,debug模式运行项目
4.访问项目