IDEA里面maven项目使用maven插件tomcat启动项目
1、首先在pom.xml添加tomcat插件依赖:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<name>javawebtest</name>
<groupId>com.maven.javawebtest</groupId>
<artifactId>javawebtest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
</dependencies>
<build>
<plugins>
<!-- tomcat插件控制 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>
8000
</port>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
添加完成之后我们打开maven菜单栏会发现在plugins里面有了一个tomcat插件:
我们双击run即可启动项目:
打开浏览器访问:http://localhost:8000/: