Go to Tomcat official website http://tomcat.apache.org/, the left sidebar under Apache Tomcat under the Maven Plugin, click in to select the latest version 2.2
With the introduction, there are two ways to configure the MAVEN plug-in using tomcat:
The first type: Add the following configuration to the <build></build> of the Pom.xml file:
1 <pluginmanagement> 2 <Plugins> 3 <plugin> 4 <groupId>Org.apache.tomcat.maven</groupId> 5 <Artifactid>Tomcat6-maven-plugin</Artifactid> 6 <version>2.2</version> 7 </plugin> 8 <plugin> 9 <groupId>Org.apache.tomcat.maven</groupId> Ten <Artifactid>Tomcat7-maven-plugin</Artifactid> One <version>2.2</version> A </plugin> - </Plugins> - </pluginmanagement>
This configuration is for a project and is only valid for one project.
The second type: Add the following configuration to the Maven Setting.xml file:
1 < plugingroups > 2 < Plugingroup >org.apache.tomcat.maven</plugingroup> 3 </ plugingroups >
This configuration on the Maven plugin will work for all projects.
Once configured, you can start the project to see the effect.
To start a project using MAVEN build, goals that column:
tomcat6:run -Dmaven.tomcat.uriEncoding=UTF-8 -Dmaven.tomcat.path=/ -Dmaven.tomcat.port=8080
or fill in:
tomcat7:run -Dmaven.tomcat.uriEncoding=UTF-8 -Dmaven.tomcat.path=/ -Dmaven.tomcat.port=8080
其中,
-dmaven.tomcat.uriencoding=utf-8 This configuration is best always add
-dmaven.tomcat.path=/This configuration can not add, the default use of/${artifactid}, where the artifactId
build Pom.xml file is written artifactId
, usually the project name. If configured as/, then access to the path is hostname:port/, if configured as/test, then the access path is hostname:port/test, equivalent to the role of NAMESAPCE.
-dmaven.tomcat.port=8080 This configuration can be set, the default is 8080
The difference between the two startup methods is that the version of Tomcat you are using is not the same. If you use TOMCAT7, you must configure Tomcat7-maven-plugin if the configuration is configured in the Pom.xml file, or build FAILURE If you configure MAVEN's Setting.xml file, it doesn't matter,<plugingroup>org.apache.tomcat.maven</plugingroup> The purpose of this line is to download all versions of MAVEN's Tomcat plugin and related plugins. The same is the case with TOMCAT6.
How to run Web projects with Maven's Tomcat plugin