Integrate the Tomcat7 plug-in with Maven

Source: Internet
Author: User

Integrate the Tomcat7 plug-in with Maven

Maven is already the standard for Java project management. Many people are concerned about how to use Maven to call Web applications during Java EE development. This article describes how to use Maven to introduce the Tomcat plug-in.

Maven Tomcat plug-ins now mainly have two versions, tomcat-maven-plugin and tomcat7-maven-plugin, basically the same way to use.

Official tomcat-maven-plugin plug-in Website: http://mojo.codehaus.org/tomcat-maven-plugin/plugin-info.html.

Tomcat7-maven-plugin plug-in Official Website: http://tomcat.apache.org/maven-plugin.html.

Tomcat-maven-plugin plug-in configuration

Add the following xml to pom. xm.

            <plugin>                <groupId>org.codehaus.mojo</groupId>                <artifactId>tomcat-maven-plugin</artifactId>                <version>1.1</version>                <configuration>                    <path>/wp</path>                    <port>8080</port>                    <uriEncoding>UTF-8</uriEncoding>                    <url>http://localhost:8080/manager/html</url>                    <server>tomcat6</server>                </configuration>            </plugin>

Brief description:

Path is the path to access the application.

Port is the tomcat port number.

UriEncoding URL according to the UTF-8 encoding, this solves the Chinese parameter garbled.

Server specifies the tomcat name.

The configuration is so simple and easy to use. Let's take a look at how to use it.

Agent running

If Maven plug-in is installed in Eclipse, right-click the pom. xml file and choose Run As> Maven build.

 

If this is the first operation, the following dialog box is displayed. Add the following command to the Goals box: tomcat: run

 

In this way, the Tomcat plug-in can run.

The following describes several common Goal

Command Description
Tomcat: deploy Deploy a web war package
Tomcat: reload Reload the web war package

Tomcat: start

Start tomcat

Tomcat: stop

Stop tomcat

Tomcat: undeploy

Stop a war package
Tomcat: run Start embedded tomcat and run the current project
Tomcat7-maven-plugin usage Configuration

The usage of the two plug-ins is basically the same. You also need to reference the plug-in pom. xml, you need to add the following configuration

            <plugin>                <groupId>org.apache.tomcat.maven</groupId>                <artifactId>tomcat7-maven-plugin</artifactId>                <version>2.1</version>                <configuration>                    <port>9090</port>                    <path>/mgr</path>                    <uriEncoding>UTF-8</uriEncoding>                    <finalName>mgr</finalName>                    <server>tomcat7</server>                </configuration>            </plugin>

The specific configuration is the same.

Plug-in usage

Note that the plug-in naming method is somewhat different. For example, to start tomcat, the target command is tomcat 7: run. Similarly, other commands also need to be changed to tomcat 7: <plug-in execution point>

OK. The configuration is so simple. If you need to trace the joint debugging in tomcat, you can use Dubug to start the maven command. For example

Maven build process details

Build a Maven repository on GitHub

Use Maven to build a Wicket project under NetBeans

Maven practice: Maven practice tutorial PDF

This article permanently updates the link address:

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.