- WTP 2.0.2 or later or Eclipse for Java EE developers bundle
- Tomcat 6.0.16 or other web application server supported by WTP
- m2eclipse 0.9.4 or later with "Maven Integration for WTP" feature installed
- Window / Preferences / Server / Installed Runtimes / Add...
- In New Server Runtime dialog select Apache, Apache Tomcat v6.0
- Select tomcat 6.0 installation
- Open "New Maven Project" wizard from File / New... / Maven Project.
- Leave default values on the first wizard page.
Select maven-archetype-webapp archetype and go to the next page.
|If no archetypes appear in this view make sure that the "Maven Central repository index" feature is installed or index for http://repo1.maven.org/maven2/ is manually registered in the Maven Indexes view|
Specify groupId, artifactId and optionally package name for generated Java classes, e.g. m2eclipse.howto and webapp and press Finish.
Wizard will create new webapp project and configure it to work with WTP.
- Right click on the project, Run As -> Run On Server
- Press Finish to let WTP create server configuration and run webapp on the server
After WTP deploys webapp and start the server you should see "Hello World!" page
- Standard Maven convention for java sources is src/main/java folder. Create this folder by drilling down to src/main then right click -> new folder. You will need right click the project and run Maven -> Update Project Configuration as you have added a new source folder.
|If you need to troubleshoot, jars for your project are located in a subfolder below \.metadata\.plugins\org.eclipse.wst.server.core\ . You will need to explore the subfolders to locate the actual location where the web application is being assembled.|
Many JEE web applications have dependencies on javax.servlet:servlet-api and javax.servlet:jsp-api. These required at compile time, but should not be packaged with web application, because they are provided by the application server (e.g. see tomcat/lib folder). The provided scope is used to handle such dependencies. Add the following lines to your pom.xml: