Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Maven project on Tomcat from Eclipse

I have a Maven Project in Eclipse. I want to deploy it in my local tomcat server and run it like normal J2EE projects.

But What i found is in tomcat add/remove projects option, no project is shown. Right click on maven project and run as doesn't have Run on Server option or may be I am missing something.

All I am looking for running Maven projects (from eclipse, no command prompt or manual copy paste of wars) in local Tomcat server just like normal J2EE projects without modifying pom.xml (seriously I don't want to modify this)

like image 766
RaceBase Avatar asked Oct 15 '12 12:10

RaceBase


People also ask

How do I run a Maven project in Eclipse?

Building and Running the Maven Project in Eclipse To run the maven project, select it and go to “Run As > Java Application”. In the next window, select the main class to execute. In this case, select the App class and click on the Ok button.

Can you use Maven with Eclipse?

Using Maven with the Eclipse IDEThe Eclipse IDE provides support for the Maven build. This support is developed in the M2Eclipse project. It provides an editor for modifying the pom file and downloads dependencies if required. It also manages the classpath of the projects in the IDE.

How do I use Tomcat in Eclipse?

For configuring the tomcat server in eclipse IDE, click on servers tab at the bottom side of the IDE -> right click on blank area -> New -> Servers -> choose tomcat then its version -> next -> click on Browse button -> select the apache tomcat root folder previous to bin -> next -> addAll -> Finish.


3 Answers

In Eclipse Maven Integration for WTP must be installed. Also this project must be configured with web nature.

UPDATE

To turn on web nature in your project properties -> Project Facets -> Convert to faceted form... -> Dynamic Web Module -> OK

like image 127
Aleksandr M Avatar answered Oct 18 '22 18:10

Aleksandr M


To complete AleksandrM answer, if someone wants to make their existing eclipse web project maven aware in Eclipse, highlight the project in explorer -> Right mouse click and select Configure -> Convert To Maven Project

like image 30
Vijay B Avatar answered Oct 18 '22 19:10

Vijay B


There can be a few reasons why you don't see the project in the Add/Remove projects dialog for Tomcat. Verify the following:

  1. You have m2e installed (http://eclipse.org/m2e/download/)
  2. You have m2e-wtp installed (http://www.eclipse.org/m2e-wtp/download/)
  3. Your Maven project imported as a Dynamic Web Application. Look for a Deployment Descriptor entry when you expand the project, it should be somewhere in the first few entries. It is the second one down for me on Eclipse Juno. Not there? It's probably not a web app. Go back and verify 1 & 2, then remove and re-import your project.
  4. Make sure that your web application is not too new for the version of Tomcat that you are using. Right-click the project and go to Properties > Project Facets. Look for Dynamic Web Module and check the version. If this version is too new for your Tomcat version, Eclipse won't let you add it. For instance, your Dynamic Web Module version is 3.0 and you're using Tomcat 6.
like image 34
davidfmatheson Avatar answered Oct 18 '22 19:10

davidfmatheson