Thursday, September 10, 2009

M2clipse and Eclipse 3.5 WTP

I want maven to manage the dependency and WTP to enable the tomcat inside eclipse. M2clipse and WTP are separated projects and they are not friendly to each other.

Before start, make sure M2clipse already installed. 

New Dynamic Web Project in eclipse.

In the wizard, change the src path, output folder and the webContent dir to be the one used by maven.

src
src/main/java
src/main/resource

output folder
target/classes

webContent
src/main/webapp

wizard1

wizard2

 

When the project is created, you can setup a tomcat server. The project created is able to be added to the tomcat server.

Maven –> Enable Dependency Management

Right click the project, Maven –> Enable Dependency Management

It will popup the window to let you input groupid, artifactid…..

Once it is done, it will generate the pom.xml and related files for m2clipse. The project is still able to be added to the tomcat server.

You may have the error “Java compiler level does not match the version of the installed Java project facet.” Change the compiler version in org.eclipse.jdt.core.prefs in the .settings. dir.

Right click the web project –> Properties –> Java EE Module Dependencies

select Maven Dependencies and the project in the same workspace. In the example below, my web project depends on the quartzspring project in the workspace.

dependencies

Publish the tomcat, look into the directory where it is deployed, check if all files are there. It works for me.

No comments:

Post a Comment