Today we’ll be looking at how to deploy to maven web project to a Tomcat server instance from within Eclipse.
- Mac OS X Lion
- Apache Maven 3.0.3 (pre-installed with Lion)
- Apache Tomcat 7.0.21
- Eclipse Indigo 3.7 (Eclipse IDE for Java Developers 1.4.1)
- m2e – Maven Integration for Eclipse 1.0.1
- Maven Integration for WTP 0.14
This post assumes that you have Maven, Tomcat, and Eclipse installed and working.
You will now need to add Maven support to Eclipse by installing the m2e – Maven Integration for Eclipse plugin. Instructions for doing this can be found here (http://www.eclipse.org/m2e/).
Once this plugin is installed, you can create a Dynamic Web Project within Eclipse and enabled the Maven project facet for it (this can be done via the context menu for the project Configure->Convert to Maven Project).
Now that we have Maven support from within Eclipse, we need to install the Maven Integration for WTP plugin so that we can deploy to a Tomcat server instance from within Eclipse via Maven. This plugin is available via the m2e Marketplace.
Open the Eclipse preferences, go to Maven->Discovery->Open Catalog and select the m2e-wtp item and click Finish. This is documented here (http://stackoverflow.com/questions/6356421/maven-tomcat-projects-in-eclipse-indigo-3-7). It should be noted some users (including myself) experienced an issue that made it so that the web project would not properly deploy until you delete the web project from Eclipse and import it again. Once this plugin is installed and working, you can deploy the web project to a Tomcat server instance, like normal, and the plugin takes care of pointing it at the appropriate maven package (WAR).