Maven Tomcat7-maven-plugin deploying MAVEN Web projects

Source: Internet
Author: User

1: Configure the Tomcat Manager User:

Re-unzipped a new TOMCAT7, open Tomcat_user.xml in the Conf directory under the Tomcat root directory, add Manager roles and users under <tomcat-users> node for Tomcat Maven Plugin automatically deploys the application with the following XML code:

<tomcat-users>    <role rolename= "Manager-gui"/>      <role rolename= "Manager-script"/>      <user username= "Alexgaoyh" password= "Alexgaoyh" roles= "Manager-gui, Manager-script"/> <!--username and password can be other character string --></tomcat-users>



Adding Tomcat Server to the 2:maven configuration

Open maven's settings.xml file, if it is a locally installed version of MAVEN, the file is installed in the root directory conf/settings.xml, if you are using the eclipse built-in maven, the file is the current system user Directory/ . M2/setting.xml. Configure the manager user information for Tomcat under the <servers> node, with the following XML code:

<servers>    <server>       <id>Tomcat7</id>       <username>alexgaoyh</username >       <password>alexgaoyh</password>     </server><servers>



The ID is used to configure the server in the Pom.xml file, with the user name and password Tomcat_user.xml in the same configuration.


3: Add the Tomcat Service to the MAVEN project:

Open the Project Pom.xml file and add the Tomcat Maven plugin plugin under the <plugins> node with the following XML code:

<build><finalName>web</finalName><plugins><plugin> <groupId> Org.apache.tomcat.maven</groupid> <artifactId>tomcat7-maven-plugin</artifactId> <version >2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <!-- The Tomcat management path--><server>tomcat7</server> <!--is the same as the server ID in the settings.xml file--><path>/web </path> < deployment location for!--applications--></configuration>     </plugin></plugins></build>



4: Deploy to TOMCAT7:

Select the project in Project view, right-click "Run as", "Maven bulid", execute Tomcat7:deploy command, you can complete the deployment, execute tomcat7:redeploy to redeploy the project, andtomcat7:undeploy Uninstall the deployment.


Problems encountered:

Connection refused error

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-snapshot:deploy (DEFAULT-CLI) on project Hello World:cannot invoke Tomcat manager:connection refused:connect [Help 1]



Cause: The tomcat server is not started

Workaround: First start the Tomcat server and select Run


Maven Tomcat7-maven-plugin deploying MAVEN Web projects

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.