Deploy Maven based Spring WAR file to Tomcat 7

In this article, we will use Maven-Tomcat plugin to deploy a WAR file to Tomcat 7. We will use A sample Spring-based application PetClinic available at

Download the application and extract the files.

Install Maven 3, Download Tomcat 7 from

Now go to apache-tomcat-7.0.68\conf\tomcat-users.xml

First, add an admin user with roles "manager-gui" and "manager-script".

<role rolename="manager-gui"/>
<role rolename="manager-script"/>

<user username="admin" password="password" roles="manager-gui,manager-script" />

53.1 tomcat-users

Now, let's add Tomcat's admin user that we created in the Maven setting file.

    <!-- Another sample, using keys to authenticate.
      <passphrase>optional; leave empty if not used.</passphrase>


Now the remaining thing is to declare a Maven-Tomcat Plugin in pom.xml. We are using sample Spring-based application PetClinic available at It already has that configuration but we need to change.

Locate Tomcat Plugin block in Pom.xml ( In my case, I changed port number to 8080. 

Make sure that Server Name (tomcat-development-server) is same that we provided in settings.xml of Maven as Id.



When we execute mvn tomcat7:deploy command, Maven deploy the WAR file to Tomcat 7 using Manager App “http://localhost:8080/manager/text” , on path “/petclinic“, using “tomcat-development-server” (in settings.xml of Maven) and username and password for basic authentication.

Before using mvn tomcat7:deploy, visit http://localhost:8080/ 

Click on Manager App; it will ask for Username and Password. Give username and password configured in the tomcat-users.xml.

Once you are authenticated properly, execute mvn tomcat7:deploy

53.2 Maven Tomcat Plugin Output

If you face proxy related issues while executing mvn command then visit- Solved: How to enable proxy setting in Maven to Download Jar files

Now Verify deployed application at http://localhost:8080/petclinic/ 

53.2 PetClinic Application


Labels: , , ,