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


In another tutorial, we saw how we could execute the mavenSW archetype:create goal from EclipseSW using an External Tool configuration. This created a maven project for us. However, although the project existed in the Eclipse workspace directory, it wasn't visible to Eclipse yet. We can make it visible to Eclipse by importing it.

One way to do this is to right-click the Navigator view and select New → Project.

New Project

This brings up the New Project popup. I selected JavaSW Project and clicked Next.

New Java Project

I selected "Create project from existing source". I clicked the Browse button and located the "mytest" project, located in my Eclipse workspace directory. I specified the project name to be "mytest" and clicked Finish.

Create project from existing source

The "mytest" project is now visible in Eclipse. We can see it in the Navigator view.

'mytest' project in Navigator View

Notice that at this point, we can see our project in Eclipse, but there are errors, which we can see in the Problems view.

Problems View

Our problem is that the project uses junit, but this dependency doesn't exist yet in our project's .classpath file. In another tutorial, we will see how to use the maven eclipse:eclipse goal to update our project's build path based on the project's dependencies specified in pom.xml. This will resolve the classpathW problems that we see above.