Accepted answer

from the command line type:

mvn eclipse:eclipse

this will add all the dependencies you have in your pom.xml into eclipse...

however, if you haven't done any of this before you may need to do one other, one time only step.

close eclipse, then run the following command from the shell:

mvn -declipse.workspace=<eclipse workspace> eclipse:add-maven-repo


mvn -declipse.workspace=/home/ft/workspaces/wksp1/ eclipse:add-maven-repo


if you use an eclipse plugin to do your maven tasks (there are 2 of them : m2ecipse from sonatype the 'official' one and q4e on google code) then, there are options in the contextual menus (right click on the project) to do that painlessly.

you can have both plugins running at the same time in your eclipse workbench and use them indifferently on a per project basis.


try:right click your project->maven->disable dependency management. and re-enable dependency management.


you could also consider to maven-dependency-plugin to your pom:


than you can run "mvn package" and maven will copy all needed dependencies to your_project_path/target/your_project_name/web-inf/lib/ directory. from there you can copy them to your project/lib dir and add as external jars (configuring your project settings buildpath)


follow these steps

1) go in projects class path

2) go in library tab

3) click on add library

4) in opened dialogue select maven managed dependencies

5) click on next

6) in the new dialogue click on manage project settings

7) in opened dialogue select the check box resolve dependencies from workspace

8) click on restore defaults

9) it will do some process and you will have all your dependencies in your library now.


likely quite simple but best way is to edit manually the file .classpath at the root of your project folder with something like

<classpathentry kind="con" path="org.eclipse.m2e.maven2_classpath_container">
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="org.eclipse.jst.component.dependency" value="/web-inf/lib"/>

when you want to have jar in your web-in/lib folder (case for a web app)


if this has not been created as a maven project but you need to add maven dependencies then right-click on project -> configure -> convert to maven project.

this will add a pom.xml file to your project.

if the pom.xml file already exists, it is already a maven project so that you can add your dependencies directly in pom.xml

now to do any other actions related to maven, you can right click on project and click maven


if you have removed maven dependency from library accidentally. add below in pom.xml



i could figure out the problem. i was getting following warning on startup of eclipse.

the maven integration requires that eclipse be running in a jdk, because a number of maven core plugins are using jars from the jdk.

please make sure the -vm option in eclipse.ini is pointing to a jdk and verify that
installed jre's are also using jdk installs

i changed eclipse.ini file and added following and restarted eclipse

c:/program files/java/jdk1.6.0_21/bin/javaw.exe

now i can see "maven dependency" library included automatically in java build path.


if maven->update project doesn't work for you? these are the steps i religiously follow. remove the project from eclipse (do not delete it from workspace) close eclipse go to command line and run these commands.

mvn eclipse:clean
mvn eclipse:eclipse -dwtpversion=2.0

open eclipse import existing maven project. you will see the maven dependency in our project.

hope this works.


if you imported an existing maven project and maven dependencies are not showing in the build path in eclipse then right click on project--> maven--> 'update project' will resolve the issue.


you can install m2eclipse and open the project as maven project in eclipse. it will create the necessary configuration and entries.

this is also useful for subsequent updates to the pom. with maven eclipse plugin, you will need to manually regenerate the eclipse configuration for each changes.


  • install m2e plugin.
  • right click your project and select configure -> convert to maven project.

enter image description here

  • then a pom.xml file will show up in your project. double click the pom.xml, select dependency tab to add the jars your project depends on.


i have the same issue using springsource tool suite. i was importing an existing maven project which ran fine from the command line. however, when i imported the project using import -> maven -> existing maven project, the project did not import correctly import and i could not add the maven managed dependencies library to the build path.

if i ran mvn install from the command line the project built successfully. if i ran mvn eclipse:eclipse and then imported into sts, then everything worked as expected, except of course i'd have to re-run this every time i updated the pom, which was undesirable.

i worked around it by running mvn eclipse:eclipse and then manually updating .classpath to eliminate the m2_repo dependencies added by eclipse:eclipse and adding the m2eclipse dependency entry:

<classpathentry kind="con" path="org.eclipse.m2e.maven2_classpath_container">
    <attribute name="org.eclipse.jst.component.dependency" value="/web-inf/lib"/>

then i imported existing maven project and it worked as expected.

this is a hack and i'm not sure what other consequences running eclipse:ecplise has when working with m2eclipse. but it did at least allow me to get my project compiling so i could get to coding.

edit 1/4/2013

the workaround i posted above will work temporarily, and i never discovered any negative side effects. however, i've had this issue a few times now and each time the problem is that there is some section of the pom that maven accepts but m2eclipse barfs on.

so i recommend removing parts of the pom 1 by 1 until you can mavenize the project successfully. just keep running maven -> update configuration after each pom edit until it works as it should. i usually start by removing the plugin configuration tag blocks one at a time, starting with the most suspicious (i.e. most complicated).

once it mavenizes properly, you can revert the pom and it should still work as expected.

after i get running, i'd research the offending configuration(s) to try to figure out what the 'proper' fix is (according to m2eclipse, anyway).

hopefully this approach leads to the permanent solution instead of settling for a hacky workaround!


make sure your packaging strategy defined in your pom.xml is not "pom". it should be "jar" or anything else. once you do that, update your project right clicking on it and go to maven -> update project...


if you have m2e installed and the project already is a maven project but the maven dependencies are still missing, the easiest way that worked for me was

  • right click the project,
  • maven,
  • update project...

eclipse screenshot

Related Query

More Query from same tag