Setup eclipse project from a Maven project

Note: Below steps will work for 2.x and later version’s of Maven project.

Assumption: You know eclipse.

Eclipse version details: I would recommend to use latest version of Eclipse (Helios was the latest version while writing this blog and steps are tried with the same).

If you know how to install eclipse plugin then you can skip install steps and install following two plugins 

  1. http://m2eclipse.sonatype.org/sites/m2e
  2. http://m2eclipse.sonatype.org/sites/m2e-extras

Install maven eclipse plug-in for more details refer.

Follow below steps to install eclipse plug-in.

  • Click on Help=> Install New Software

  • Click on Add button on Install window.

Once you install both the eclipse plug-ins for Maven your eclipse is ready to import Maven project. When you install those plug-in’s it also installs Embedded Maven and it uses the same for imported projects. If you want to use other version of maven which installed on your machine. You can do the same follow below steps to select installed version of Maven.

  • Click on Window=> Preferences

  • On Preferences window expand Maven and select Installations.
  • Under Installations option click on Add to select maven installation installed in previous steps.
  • When you click on add, it will pop up a folder browser window. Select the home location of maven installation in that Window.

  • Once you select the maven installation home folder click on Apply and then click on OK.

To setup eclipse project for your maven project follow below steps.

  • Click on menu File=> Import...

  • On Import Window expand Maven tag and select Existing Maven Projects. And click on Next button.

  • On Import Maven Projects window click on Browse and select your base project folder which contains pom.xml. If you have multiple projects with one parent project. Just select the folder of parent project.

  • Once you select the base folder it will show you the project/projects. Click on Finish button. It will setup the required project/projects for you.

  • It creates required project as per packaging type. If packaging type is war it will create eclipse web project. It will add corresponding resources into source path, add web resource and also add dependencies inside classpath.

See also