Friday, 27 July 2012

How to Deploy a .war to Tomcat 7 via Maven?

In order to deploy a .war to Tomcat 7 during a maven build process, the cargo plugin is very useful.

One should add the following plugin in your pom.xml:

The remote URI is configured to deploy the .war on a local Tomcat 7 installation listening to port 8080. The host could be a remote host too (one should use https instead for security).

The profile used to connect to maven must be configured with proper roles in the /conf/tomcat-users.xml file where Tomcat is installed, as following:
    <user name="admin" password="admin"
       roles="admin-gui,manager-gui,manager-script" />

Then you can use the following maven goals to deploy or redeploy your application:
More Maven tips & tricks here.