How do I create a maven web application project from Eclipse?
Author: Deron Eriksson
Description: This tutorial describes how to create a web application project using maven from Eclipse.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

Page: < 1 2 3

(Continued from page 2)

Notice that the project has a bin directory for the project *.class files. A mavenSW project by default stores its generated classes in the target/classes directory. Therefore, it's clear that we need to set its .classpath to be the correct maven format.

In another tutorial, I created an EclipseSW external tool configuration to perform a "mvn eclipse:eclipse" goal. So, I'll select "mywebapp" and execute the "mvn eclipse:eclipse" external tool on "mywebapp".

Executing 'mvn eclipse:eclipse' on 'mywebapp' project

The "mvn eclipse:eclipse" command generates the following console output:

'mvn eclipse:eclipse' console output

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building mywebapp Maven Webapp
[INFO]    task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse]
[INFO] Using source status cache: C:\dev\workspace\mywebapp\target\
[INFO] Not writing settings - defaults suffice
[INFO] File C:\dev\workspace\mywebapp\.project already exists.
       Additional settings will be preserved, run mvn eclipse:clean if you want old settings to be removed.
[INFO] Wrote Eclipse project for "mywebapp" to C:\dev\workspace\mywebapp.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Tue Feb 05 12:53:54 PST 2008
[INFO] Final Memory: 3M/7M
[INFO] ------------------------------------------------------------------------

After the project is refreshed, it now has a target directory with a classes directory for generated *.class files. I deleted the bin directory since it is no longer used. The final "mywebapp" project in the Navigator view is shown below:

'mywebapp' project in Eclipse Navigator View

Our maven web application project has been created and now can be debugged in Eclipse.

Page: < 1 2 3