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
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
Addbutton onInstallwindow.
- On
Add Repositorywindow add any meaning full name like in this casemavenand the corresponding URL for eclipse plugin (http://m2eclipse.sonatype.org/sites/m2e). And click onOkbutton.
- check all required and click on
Nextfollow the wizard and finally finish. It will install the plugin. - similarly install m2eclipse Extras URL (http://m2eclipse.sonatype.org/sites/m2e-extras).
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
Mavenand selectInstallations. - Under
Installationsoption click onAddto 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
Applyand then click onOK.
To setup eclipse project for your maven project follow below steps.
- Click on menu
File=> Import...
- On
ImportWindow expandMaventag and selectExisting Maven Projects. And click onNextbutton.
- On
Import Maven Projectswindow click on Browse and select your base project folder which containspom.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
Finishbutton. It will setup the required project/projects for you.
- It creates required project as per packaging type. If packaging type is
warit will create eclipse web project. It will add corresponding resources into source path, add web resource and also add dependencies inside classpath.