How to Deploy a Maven Webapp to Tomcat

Assuming you have just installed and begun tomcat on your server, the time has come to deploy our basic Java web application to tomcat dedicated server. We simply need to configure few things and call a maven module and we will be up and running in the blink of an eye.

Step 1- Configure a Tomcat User

Open the <tomcat>/conf/tomcat-users.xml document after that enter the lines given below. On the off chance that there are as of now tomcat users characterized in the xml document then simply include the new role and user to the previous list.


 <role rolename="manager"/>
 <role rolename="administrator"/>
 <user username="administrator" password="administrator" roles="administrator,manager"/>

Presently we can get to the tomcat manager (http://localhost:8080 and hit "Tomcat Manager") with username administrator and password administrator.

We likewise now have the authorization to deploy applications to Tomcat Dedicated Server.


Step 2- Configure maven to have the capacity login to the tomcat manager application.

Open <maven>/conf/settings.xml after that enter the following lines to the <servers> list:


Step 3- After the pom.xml file to add the tomcat-maven-plugin

In Eclipse, open the pom.xml record and replace the current <build> with the accompanying:


What is the role of this plugin? Maven will download this plugin code at present, on the off chance that you don't as of now have it in your local repository. This module will arrange and deploy the application to tomcat. You don't have to do whatever else!

Step 4- Deploy the application to Tomcat


Accepting tomcat is now up and running enter the accompanying in TERMINAL:


$ cd MonsoonGreetings
$ mvn tomcat:deploy


At present you can open a web browser in your system with the url http://localhost:8080/MonsoonGreetings/



Step 5- Make a change in Eclipse, redeploy

Open the document index.jsp in Eclipse and modify "Hi World!" to "Welcome to Monsoon Greetings!" and afterward redeploy in TERMINAL:


$ mvn tomcat:redeploy