he Eclipse Web Tools Platform (WTP) and the M2Eclipse (M2) plugin are separate projects, each with high value for the developer who uses Eclipse. WTP is a tools bundle that extends the Eclipse platform for web and Java EE application development, while M2 integrates Maven tightly into the IDE. Leveraging both in the same project has compelling benefits for the developer. Unfortunately, Eclipse has yet to offer WTP and M2 integration OOTB (that's Out Of The Box, if you didn't know). That's where this article comes in.
This article demonstrates basic web application development using both WTP and M2 as an integrated solution. By walking through a project-building exercise from setup through deployment, it will enable you to speed up your own Eclipse-based Java web development by applying the same process.
The primary development environment for the project described in this article is Eclipse. Your Eclipse environment must include the following technologies to complete the exercise.
|Figure 1. Server Configuration: Follow these steps to configure the server.|
See Sidebar 1 for a more complete list of Eclipse download links.
WTP and M2Plugin Configurations
Before you begin, you must set some initial server, browser, and Maven configurations. In fact, when you launch Eclipse with the M2 plugin you may see an error message regarding a settings.xml file. Ignore the message. It will be resolved shortly.
Configure your server to run the web application. From the Eclipse menu, follow these steps to configure the server (see Figure 1): Windows→Preferences→Server→Installed Runtimes→add.
Select the appropriate version of Tomcat. In the next page of this wizard screen, browse to the Tomcat home directory and press "finish."
|Figure 2. Maven Settings: Navigate through Eclipse Menu→Window→Preference and click on Maven in the left panel.|
When you launch a web application using WTP, it opens in an internal browser. You may prefer to have your web applications open in an external browser of your choice. If so, configure the external browser to launch using the Eclipse menu path Window→Web Browser.
Navigate through Eclipse Menu→Window→Preference and click on "Maven" in the left panel. This may take a short while. If so, please wait. Note the file path mentioned in the "User Settings file" field (see Figure 2). Ensure a valid settings.xml file is present in this location. If you don't have a valid settings.xml file there, copy it from apache-maven-2.0.8\conf. Press the "OK" button.
Now you can start the actual work of creating a dynamic WTP project and integrating it with the M2 plugin.