新建maven web項目,首先保證maven環境OK,maven項目能正常install
1、pom.xml文件配置如下:
<build> <pluginManagement> <plugins> <!-- 配置Tomcat插件 --> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>80</port> <path>/</path> </configuration> </plugin> </plugins> </build>
2、eclipse工具中,使用Run as ->Maven Build->在goals中輸入 tomcat7:run即可