HOW-TO: Create Java Web Application with Eclipse WTP and m2eclipse
Requirements
- Java JDK6
- Eclipse 3.5 for JEE developers – http://www.eclipse.org/downloads/
- Maven2 – http://maven.apache.org
- Tomcat 6 server – http://tomcat.apache.org/download-60.cgi
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):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: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.Download
Sample Eclipse project: wtp-m2eclipse-demoDevelopment Manager and Java Developer at Goyello. Open source enthusiast, team leader, teacher, blogger and Twitter user @kolorobot