Deploying a project using the Tomcat plugin in an Eclipse MAVEN project

Source: Internet
Author: User

MAVEN's Tomcat plug-in Deployment Web project, I simply think that there are two kinds, one is to deploy to the built-in Tomcat, and the other is to deploy to the installation of Tomcat.

The first deployment, the default is the 8080 port deployed in the built-in Tomcat, if you do not need to change the port and other settings, you can not configure the Tomcat plugin in the POM

If you need to change the port, refer to the following configuration:

<build> <plugins>  <plugin>   <groupId>org.codehaus.mojo</groupId>   < artifactid>tomcat-maven-plugin</artifactid>   <version>1.1</version>   < configuration>    <path>/Demo1</path>    <port>8088</port>    <uriencoding >UTF-8</uriEncoding>    </configuration>  </plugin> </plugins></build>

then execute mvn clean tomcat:deploy, and finally MVN Tomcat:run can start the built-in Tomcat.

Built-in Tomcat deployment is simple, the following is mainly about the locally installed Tomcat deployment

1. Preparatory work

Download the installation and configure Tomcat and Maven.

Prepare a MAVEN Web project.

2. MAVEN deployment Web project to Tomcat configuration

2.1 MAVEN automatic deployment is actually tuned to the manager feature in the Tomcat installation directory. In order to access the Http://localhost:8080/manager page normally, we need to modify the Tomcat-users.xml in the $tomcat_home/conf directory:

<tomcat-users>  <role rolename= "Tomcat"/>  <role rolename= "manager"/>  <role Rolename= "Manager-gui"/>  <role rolename= "Manager-script"/> <role  rolename= "Admin-gui"/>  <user username= "Tomcat" password= "Tomcat" roles= "Tomcat,manager,      Manager-gui,manager-script,admin-gui "/></tomcat-users>

PS: Using MAVEN's Tomcat plug-in to deploy the project, my understanding is to invoke the Manager-script permission, execute the command in a script, Manager-gui should be the interface way to deploy, that is, like WebLogic to open the management page, Choose your project deployment after you finish. The individual feels that has the Manager-script authority to be possible.

2.2. Modify Maven's Settings.xml

Locate Settings.xml in the $USER_HOME/.M2 directory and add the server node:

<servers>    <server>       <id>tomcat</id>       <username>tomcat</username >       <password>tomcat</password>    </server></servers>

2.3. Modify Pom.xml add tomcat Maven Plugin

I use the tomcat6,pom.xml to add the following configuration:

...
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> < artifactid>tomcat-maven-plugin</artifactid> <version>1.1</version> < configuration> <path>/Demo1</path> <port>8080</port> <uriencoding >UTF-8</uriEncoding> <url>http://localhost:8080/manager/html</url> <server >tomcatServer</server> <username>tomcat</username> <password>tomcat</ password> </configuration> </plugin> </plugins></build>

If it is a TOMCAT7 plugin:

<properties>        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>        < spring.version>3.2.2.release</spring.version>        <finalName>web-loab</finalName>    </properties>    <build>        <plugins>            <plugin>                <groupId> org.apache.tomcat.maven</groupid>                <artifactId>tomcat7-maven-plugin</artifactId>                <configuration>                    <url>http://localhost:8080/manager/text</url>                    <server>tomcat </server>                    <username>tomcat</username>                    <password>tomcat</password>                    <path>/Demo1</path>                </configuration>            </plugin>        </plugins>    </build>

Above username, password from tomcat-users.xml. The server's ID from the server specified by Settings.xml. Path is the way to access the app. The URL specifies the Tomcat Management page path.

2.4. Deploy the project to Tomcat

MVN Clean Tomcat:redeploy

Then MVN Tomcat:run can start the locally installed Tomcat with the plugin.

PS: In addition I heard that the MVN Tomcat plugin can only start a project, in practice, found that this is the case, but did not find information to confirm, we have comments and suggestions please enlighten.

Reference Document: http://my.oschina.net/feichexia/blog/326893

Deploying a project using the Tomcat plugin in an Eclipse MAVEN project

Related Article

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.