Eclipse+maven remote deployment project into Tomcat

Source: Internet
Author: User
Tags tomcat server

Using MAVEN's auto-deploy feature makes it easy to automatically package MAVEN projects and deploy them to remote tomcat servers, eliminating tedious operations and saving time.

The version of Tomcat I use is 8.5,TOMCAT7 and TOMCAT8, and the installation configuration process is relatively straightforward and omitted here.

Here's my installation deployment process:

1. Configure Tomcat

First modify the Tomcat-users.xml file, which is under the Conf folder of the installation directory, mine is in/usr/local/apache-tomcat-8.5.11/conf, in <tomcat-users></ Add in the tomcat-users> node:

<role rolename= "Manager-gui"/><role rolename= "Manager-script"/><user username= "Tomcat" password= " Tomcat "roles=" Manager-gui, Manager-script "/>

Change the password above to your own password, noting that for tomcat9, you cannot give the user Manager-script and Manager-gui roles at the same time.

Save Tomcat-users.xml.

Create a Manager.xml file under the conf/catalina/localhost/directory of the Tomcat server and write the following values:

<?xml version= "1.0" encoding= "UTF-8"? ><context privileged= "true" antiresourcelocking= "false"         docbase= "${catalina.home}/webapps/manager" >             <valve classname= "Org.apache.catalina.valves.RemoteAddrValve" allow= "^.*$"/></context>

The above copy can be, by default, Tomcat Manager and Host-manager only accept the native request, and to allow it to accept the remote request, you need to add the above mentioned Manager.xml configuration.

Save exit. Then execute startup.sh boot tomcat under the bin directory.

Then enter http://serverip:port/manager/html in the browser, the request to enter the user name and Password dialog box, enter the Manager-gui corresponding user and password login to the management console (where ServerIP is the server IP, If the server is localhost or 127.0.0.1, the port is Tomcat port, default 8080). To confirm that the manager is configured correctly. Examples of correct results are as follows:

2. Configuring in the MAVEN project

In the Pom.xml file, add the following plugin node under the plugins node:

     <plugin>      <groupId>org.apache.tomcat.maven</groupId>    <artifactId> tomcat7-maven-plugin</artifactid>    <version>2.2</version>    <configuration>        <url>http://192.168.199.201:8080/manager/text</url>        <username>tomcat</username>        <password>tomcat</password>        <update>true</update>        <path>/test_mvn </path>    </configuration>        </plugin>

Replace the ServerIP and port above with the IP and ports of your Tomcat server. The password is replaced with the password for the MANAGER-SCRIPT role configured above. Path to the project's deployment paths in the Tomcat server.   


Then deploy, if it is the first deployment, run Tomcat7:deploy for automatic deployment (for tomcat8,9, also using the TOMCAT7 command), if you are updating the code after you redeploy the update, run Tomcat7:redeploy, If the first deployment uses Tomcat7:redeploy, only the upload war file will be executed and the server will not automatically decompress the deployment. if the path already exists in the Tomcat server and uses the Tomcat7:deploy command, the configuration above must be configured <UPDATE>TRUE</UPDATE>

Eclipse+maven remote deployment project into Tomcat

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.