Note to self: Eclipse + Maven + Tomcat

I decided once again to try out Maven but this time I wanted to use it from Eclipse and get everything automatically setup for a proper web project with automatic deploy in a Tomcat.

The first lesson was not to use the system installed version of Eclipse – it just proved too difficult when adding plugins not in the system repositories (Fedora in this case). So off to eclipse.org to get the latest version of Eclipse IDE for Java EE Developers.

Next I went looking for a Maven plugin to Eclipse and found m2eclipse. The important part for creating a successful web project is to install both m2eclispe Core and m2eclipse Extras. Read the m2eclipse installation instructions.

When creating a new project in Eclipse select “Maven/Maven Project”. For the archetype I selected “maven-archetype-webapp”. Go to the project properties and look in the “Project Facets” to configure the needed version of the Servlet API, etc. On one project I created I had to manually edit the .project file to get the “Project Facets” entry – I had to add the line

<nature>org.eclipse.wst.common.project.facet.core.nature</nature>

to convince Eclipse that I had in fact created a web project.

Now open the “Servers” view and add a new Tomcat server. Right click this new server and select “Add and Remove…”. In the new dialog box add the new project. Now click the server to start it and it should automatically deploy the new project.

Leave a Reply

*