直接在POM.XML中添加以下內容
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8888</port>
<path>/</path>
<contextFile>src/main/webapp/META-INF/context.xml</contextFile>
</configuration>
</plugin>
該插件會自動下載一個嵌入式的TOMCAT,可以在configuration配置節里面對這個嵌入式的TOMCAT配置端口,目錄和content.xml信息。
要運行這個TOMCAT,需要在IDEA-RUN-DEBUG,editconfiguration,新增-MAVEN,名稱輸入TOMCAT7,commandline為:tomcat7:run
關於tomcat7-maven-plugin的官方信息見:http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/usage.html