views:

116

answers:

2

I have created a J2EE project using maven and would like to import it as a J2EE project (ie: auto have the libs jars added to the classpath, tomcat jars to classpath, etc). How can I change an existing project to a J2EE project?

+2  A: 

Use the m2eclipse plugin. It will tell Eclipse which JARs to include and you can manage all your dependencies in the pom.xml.

Aaron Digulla
+2  A: 

Both the maven-eclipse-plugin and the Eclipse M2Eclipse plugin can handle this use case and make Eclipse treat your war/ejb/ear projects as WTP projects.

For the maven-eclipse-plugin, check the WTP support page (you can of course add this parameter to the <configuration> element of the plugin).

For the M2Eclipse plugin, make sure you also install the Maven Integration for WTP (which is optional) or you won't get WTP support. Note that for a war module, the plugin will set the Dynamic Web Module facet version on the basis of the version of web.xml (2.3, 2.4, 2.5) and the version can't be changed once the project has been imported. So make sure to have the "right" web.xml before the import (or delete the project from the workspace, change the web.xml and re-import the project).

Pascal Thivent
I am using m2eclipse - even when creating a project through the Eclipse m2eclipse gui, it still does not show the project as a web project... Meaning, there is no icon of a globe, and there is no option to run the project as "run on server"... I do have Maven Integration for WTP...
wuntee
@wuntee Is the WTP working for other (non maven) projects? What is the packaging of the created project?
Pascal Thivent
after updating all of eclipse it started working fine. thanks.
wuntee