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?
Use the m2eclipse plugin. It will tell Eclipse which JARs to include and you can manage all your dependencies in the pom.xml
.
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).