MAVEN automated deployment projects and frequently asked questions resolved

Source: Internet
Author: User

MAVEN automatically deploys war to Tomcat
1. Configure the following information in the MAVEN project Pom

<build><finalName>dianxiao</finalName><!--The name of the war package--><plugins><plugin>< groupid>org.codehaus.mojo</groupid><artifactid>tomcat-maven-plugin</artifactid>< Version>1.1</version><configuration><url>http://localhost:8080/manager/text</url> <!--the deployment path for Tomcat, the path for TOMCAT6 is HTTP://LOCALHOST:8080/MANAGER,TOMCAT7 configuration path is Http://localhost:8080/manager/text-- ><username>admin</username><password>admin</password><path>/dianxiao</path ></configuration><executions><execution><id>tomcat-deploy</id><phase> deploy</phase><goals><goal>deploy</goal></goals></execution></ Executions></plugin></plugins></build>

  

2. Add the following information to Tomcat's Tomcat-users.xml
<rolerolename= "Manager"/>
<userusername= "admin" password= "admin" roles= "manager"/>
3. Start Tomcat

4. Run Maven build ...
Fill in the package Tomcat:redploy in goals, click Run
5. Look at the files under Tomcat's WebApps to see if there are two more files, including the war package, if it appears, it will succeed! Instead start looking for errors, refer to the following

In the deployment process of Maven and Tomcat, the most common errors are three, tossing for half a day, finally found the cause of three kinds of errors, and the corresponding perfect solution

1.Connection refused error

The error message is as follows

[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

2.401 Error

The error message is as follows:

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-snapshot:deploy (DEFAULT-CLI) on project Helloworld:cannot invoke Tomcat Manager:server returned HTTP response code:401 for url:http://localhost:8080/manager/t Ext/deploy?path=%2fhelloworld, [Help 1]

Cause: Permission Issues

Solution in $catalina_base/conf/tomcat-users.xml,

Add permissions like the D:\apache-tomcat-7.0.34\conf\tomcat-users.xml file

<role rolename= "manager"/><user username= "admin" password= "admin" roles= "manager"/>

Modify Pom.xml file in <configuration>

Add in </configuration>

<username>admin</username>  <password>admin</password>

3.403 Error

The error message is as follows:

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-snapshot:deploy (DEFAULT-CLI) on project Helloworld:cannot invoke Tomcat Manager:server returned HTTP response code:403 for url:http://localhost:8080/manager/h Tml/deploy?path=%2fhelloworld, [Help 1]

Cause: The problem is likely to occur for two reasons, see the solution specifically

Workaround:

1) If you are using Tomcat 7, you need to modify the URL address of the deployment in Pom.xml.

<url>http://localhost:8080/manager</url>

Change

<url>http://localhost:8080/manager/text</url>

On the issue of this deployment, I just encountered a URL problem, I use TOMCAT7

2) Manager-gui and Manager-script permissions are required for Tomcat user rights assignment

The correct conf/tomcat-users.xml configuration should be:

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

Reference article: http://my.oschina.net/jerryhu/blog/295279

MAVEN automated deployment projects and frequently asked questions resolved

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.