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
Add
button onInstall
window.
- On
Add Repository
window add any meaning full name like in this casemaven
and the corresponding URL for eclipse plugin (http://m2eclipse.sonatype.org/sites/m2e). And click onOk
button.
- check all required and click on
Next
follow 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
Maven
and selectInstallations
. - Under
Installations
option click onAdd
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 onOK
.
To setup eclipse project for your maven project follow below steps.
- Click on menu
File=> Import...
- On
Import
Window expandMaven
tag and selectExisting Maven Projects
. And click onNext
button.
- On
Import Maven Projects
window 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
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.