In last tutorial, you created a web application with Maven. Here’s a guide to show you how to convert that web application to support Eclipse IDE.

Eclipse IDE support web application via WTP tool, so you need to make your Maven based project support it as well.

1. mvn eclipse:eclipse -Dwtpversion=2.0

To convert a Maven based Java project to support IDE, you use this command :

mvn eclipse:eclipse

For web application, you need extra parameter to make it support Eclipse’s wtp, instead, you should use this command :

mvn eclipse:eclipse -Dwtpversion=2.0

See output …

D:\workspace-new\mkyongweb-core>mvn eclipse:eclipse -Dwtpversion=2.0
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'eclipse'.
[INFO] ------------------------------------------------------------------------
[INFO] Building mkyongweb-core Maven Webapp
[INFO]    task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse {execution: default-cli}]
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: D:\workspace-new
[INFO] no substring wtp server match.
[INFO] Using as WTP server : Apache Tomcat v6.0
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAINER
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "mkyongweb-core" to D:\workspace-new\mkyongweb-core.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Fri Apr 15 11:51:53 SGT 2011
[INFO] Final Memory: 7M/14M
[INFO] ------------------------------------------------------------------------

2. Eclipse WTP

Standard Eclipse’s “.classpath” and “.project” files are created. And you will noticed a new “.setting” folder is created and inside contains “org.eclipse.wst.common.component” and “org.eclipse.wst.common.project.facet.core.xml“, both files for WTP or Faces support in Eclipse.

File : org.eclipse.wst.common.project.facet.core.xml

  <fixed facet=""/>
  <fixed facet="jst.web"/>
  <installed facet="jst.web" version="2.4"/>
  <installed facet="" version="1.4"/>
Maven 2.x generated web application with JDK1.4 (see above), which is rather outdated, you may need to upgrade it to latest JDK version.

File : org.eclipse.wst.common.component

<project-modules id="moduleCoreId" project-version="2.0">
  <wb-module deploy-name="mkyongweb-core">
    <property name="context-root" value="mkyongweb-core"/>
    <wb-resource deploy-path="/" source-path="src/main/webapp"/>
    <property name="java-output-path" value="/target/classes"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>

3. Import into Eclipse IDE

Now, you have everything what a Eclipse web application want, so, you can start import your Maven based web application into Eclipse IDE.

Steps :
In Eclipse IDE, menu bar , File -> Import… -> General -> Existing Projects into Workspace -> select root directory (select your project folder) -> Done.

Convert Maven based web application to support Eclipse IDE



  4. Unsupported WTP version: 1.5. This plugin currently supports only the following versions: 1.0 R7
  5. How to convert Java Project to Web Project in Eclipse
Tags :
Founder of and, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Related Posts

Popular Posts