On daily basis we use Eclipse as a primary IDE for developing Java applications. We also are tightly coupled with Apache Maven as our main project management tool. A well known plugin that integrates Apache Maven into Eclipse is m2eclipse. One of its main features is the integration with Web Tools Project (WTP). In this short tutorial I will present how to start and configure Java Web Application using m2eclipse .
m2eclipse plugin may be installed via http://m2eclipse.sonatype.org/sites/m2e update site (Help > Install New Software). It is also required to install (at least) WTP support for m2eclipse from extras update site: http://m2eclipse.sonatype.org/sites/m2e-extras:
If you plan to use Subversion or CVS also install SCM support and proper SCM handler.
Now let’s change the default Maven installation for m2eclipse from embedded to our fresh Maven installation (Preferences > Maven > Installation):
The sample application will run on Tomcat 6 within Eclipse. To make it possible, define the new Tomcat 6 server. Select New > Other > Server. Click Next. Choose Tomcat 6 from Apache group and click Next. Finish:
Tomcat 6 server
Create Web Application
We are ready now to create a new Web Application. Select New Project Wizard and choose Maven Project from the list. In Archetype selection panel select maven-archetype-webapp as shown below:
Finish the project creation by filling archetype parameters:
Once project is created, navigate to JEE perspective to see its default layout:
Running the application
Right click on the application and select Run On Server. From the server list select Tomcat v6.0 server created earlier and click finish.
That’s it. You can build up your application with your favorite Eclipse without losing any of its great features. And you still benefit from Maven.