eclipsespring-mvcmaven-tomcat-pluginembedded-tomcat-8embedded-tomcat-7

How to run a spring web app without a full Tomcat install?


I just began learning Spring MVC, using this tutorial.

Entire write and build (under Eclipse) went successfully and a target .war file is generated.

However, I need to test-run it and I do not wish to download and install Tomcat at the moment.

I have heard there is a way to run it from within Eclipse without requiring a full-fledged Tomcat installation. How do I do that?


Solution

    1. Add to your pom.xml the tomcat-plugin:

    `

      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <path>/</path>
        </configuration>
      </plugin>
    

    `

    1. In Eclipse, add a debug/run configuration for Maven Build: Right-click New, and in that new configuration's Goals enter: clean install tomcat7:run

    2. Now run that configuration (right-click pom.xml > Run as > Run configuration)