From Eclipse, how can I run my Maven project in Tomcat?

within Eclipse, you can run the project by doing the following:

In the servers view, create a server (right-click, new Server, Tomcat) Add the project to the server (right-click the server, add & remove, select the project) Start the server - the server will start & deploy the app

The trick to this is that the server does not deploy the packaged app in the tomcat webapps directory, it deploys an exploded version into a directory under the plug-ins directory of the eclipse installation.

To specifically do the maven packaging and deploy to the external tomcat istance (external to eclipse), use the tomcat-maven-plugin, as specified by fmucar


see below link for details

http://mojo.codehaus.org/tomcat-maven-plugin/deployment.html

Alternatively, search for tomcat:run and you can use it directly

EDIT:

Run/Debug Configurations

Double click maven build, a new configuration will be created

put ${project_loc} for base directory

put tomcat:run for goals

give an appropriate name for yourself at the top

Apply and run/debug using your new configuration

EDIT2:

The link has been changed to below one: http://tomcat.apache.org/maven-plugin-trunk/tomcat7-maven-plugin/ (Thanks @Lucky)