Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm on Windows XP, using Eclipse Indigo, Tomcat 6.0.33, and have the Maven plugin installed. (Using Maven 3.0.3 on my system). I have Tomcat showing up in my Eclipse servers list, but I can't figure out a one click way to deploy my WAR project to the Tomcat server. When I right click my project and select "Run" there are many Maven options (e.g. "Maven Install"), but none builds and then deploys my project to Tomcat.

Any help along these lines? Thanks, - Dave

like image 453
Dave Avatar asked Oct 11 '11 13:10

Dave


People also ask

How do I run a Maven project with Maven in Eclipse?

First of all, select the project and go to “Run As -> Maven Build”. The “Edit Configuration” popup window will open. Enter the “Goals” as “package” to build the project and click on the Run button.

How do I open tomcat in Eclipse?

Go to the project in the Project Explorer, select the web project, right click and select "Run As", you will see Apache Tomcat, create runtime configuration for the web project by selecting "New" button.


2 Answers

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)

like image 146
fmucar Avatar answered Sep 28 '22 04:09

fmucar


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

like image 26
TrueDub Avatar answered Sep 28 '22 05:09

TrueDub