How to use maven plug-in to deploy project to remote running environment

Are you still using FTP to upload your War package? Here's a simpler and easier way to use. That's maven's cargo plug-in.

Cargo is a set of tools to help users operate Web containers. It can help users realize automatic deployment, and it supports almost all Web containers, such as Tomcat, JBoss, Jetty and Glassfish. Cargo provides Maven integration through cargo-maven 2-plugin, which can be used by Maven users to deploy Web projects into Web containers.

Cargo supports two modes of local deployment,

  1. A remote deployment mode. Local deployment can be divided into standalone mode and existing mode. In the standalone mode, Cargo will copy a copy of the configuration from the installation directory of the Web container to the directory specified by the user, and deploy the application.
  2. In the existing mode, the user needs to specify the existing Web container configuration directory, and then Cargo will directly use these configurations and deploy the application to its corresponding location.

1. Configuring in maven

                    <!--Tomcat Version 7 x 8x-->
                    <type>remote</type><!--Remote deployment-->
                        <cargo.hostname>Your server's IP</cargo.hostname><!--ip-->
                        <cargo.servlet.port>Port of your server</cargo.servlet.port><!--port-->
                        <cargo.remote.username>admin</cargo.remote.username><!--Account password-->
                        <cargo.remote.password>lushuifa</cargo.remote.password><!--Account password-->
                        <!--Access path-->

2. How to use it in idea is shown in the figure below

3. Corresponding configuration of server tomcat

tomcat is mainly configured with users, passwords and roles. Those who don't care can baidu.

<role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <user username="user name" password="password"  roles="manager-gui,manager-script,manager-jmx,manager-status" />

Tags: Tomcat Maven ftp Jetty

Posted on Sun, 17 May 2020 08:37:07 -0700 by Haggen