Direct deployment of Web applications to Tomcat using Maven

Source: Internet
Author: User

Direct deployment of Web applications to Tomcat using Maven
1. Download and decompress Tomcat and configure environment variables so that Tomcat can be started successfully.

The decompressed version of tomcat allows you to conveniently view error information output by tomcat in the background for debugging.

2. Configure the username and password for tomcat.

Modify the/config/tomcat-user.xml under the tomcat installation directory to the following:

<?xml version='1.0' encoding='cp936'?><tomcat-users><role rolename="manager-gui"/>  <role rolename="manager-script"/>  <user username="username" password="password" roles="manager-gui,manager-script"/></tomcat-users>
  • 1

The preceding configuration file is used to add a user named "username", "password", and "manager-gui" to tomcat.

3. Add the following code to the pom. xml file of the maven project.
<plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-compiler-plugin</artifactId>            <version>2.3.2</version>            <configuration>                <source>1.7</source>                <target>1.7</target>            </configuration>        </plugin>        <plugin>              <groupId>org.apache.tomcat.maven</groupId>              <artifactId>tomcat7-maven-plugin</artifactId>              <version>2.2</version>              <configuration>                  <url>http://localhost:8080/manager/text</url>                  <username>username</username>                  <password>password</password>                  <path>/${project.artifactId}</path>              </configuration>          </plugin>     </plugins>
  • 1
4. Deploy the application

If eclipse is used, right-click the project and choose Run As> Maven build... -> Enter Tomcat 7: deploy in Goals;
If Maven is used directly, run the following command:

mvn tomcat7:deploy

Maven official guide _ Chinese full version clear PDF

Maven 3.1.0 release, Project Build Tool

Install Maven in Linux

Maven3.0 configuration and simple use

Set up sun-jdk and Maven2 in Ubuntu

Get started with Maven

This article permanently updates the link address:

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.