Steps to configure and run maven web application using tomcat

For maven web application, it can be run in tomcat server without installing tomcat server locally!!

Yes, its true!!

Here maven provides a plugin for tomcat instance, which will used to deploy and run the web application using a simple maven command “tomcat7:run”.

For this, first we have to configure the web application’s pom.xml with following plugin configuration.

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <path>/${project.build.finalName}</path>
    </configuration>
</plugin>

Here path is used to configure the root context for the application.

After adding the above, just use the maven command mvn tomcat7:run to run this application in tomcat server.

Leave a Reply

Your email address will not be published. Required fields are marked *