How to run Web projects with Maven's Tomcat plugin

Source: Internet
Author: User
Tags apache tomcat

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.