Over a million developers have joined DZone.
Platinum Partner

How-To: Auto Deploy A Web Application In Tomcat Using The Maven Cargo Plugin

The Web Dev Zone is brought to you in partnership with Mendix.  Discover how IT departments looking for ways to keep up with demand for business apps has caused a new breed of developers to surface - the Rapid Application Developer.

In the previous section we copied the WAR file manually under TOMCAT_HOME/webapps folder. Here we will automate the deployment using cargo plugin. Include the code below in pom.xml under the project root directory [E:\theacodefactory\code\airelinesweb\airlines as in the example considered].

The cargo plugin details should be copied under build/plugins. The values to be changed are in bold. Please change the values as per your requirement.


I have provided a user tomcat with password also as tomcat. The user tomcat has a manager role. This configuration is done in tomcat-users.xml under TOMCAT_HOME/conf folder as in the screenshot below.

<xml version='1.0' encoding='utf-8'?>
<role rolename="manager"/>
<user username="tomcat" password="tomcat" roles="manager"/>

To deploy using the Maven - cargo plugin use the command mvn cargo:deploy as in the screenshot. [To undeploy it is mvn cargo:undeploy. You may also use cargo:redeploy].


Note: The Tomcat server should be started before you execute cargo related Maven commands.

The Web Dev Zone is brought to you in partnership with Mendix.  Learn more about The Essentials of Digital Innovation and how it needs to be at the heart of every organization.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}