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 .
Requirements
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:

m2eclipse settings
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):

m2eclipse settings
Server
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:

Archetype selection
Finish the project creation by filling archetype parameters:

Archetype parameters
Once project is created, navigate to JEE perspective to see its default layout:

Project 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.
Download
Sample Eclipse project:
wtp-m2eclipse-demo Tagged as:
eclipse,
m2eclipse,
maven
IT professional, open source enthusiast, certified Java developer, team leader. Follow me on twiiter: kolorobot
Rafał has written 16 awesome articles.
You can read more posts written by Rafał when you click here.
Pingback: Skype and Agile software development were really hot on our blog this year
Pingback: Maven with Eclipse | László GRAD-GYENGE