Missing Maven dependencies in Eclipse project
Solution 1
Problem solved!
I don't know what exactly solved it, but I did 4 things in Eclipse:
- Window->Preferences: Maven->Installations: Global settings -> open file and hardcoded localRepository
- Project->Clean
- right click on project: Maven->Update dependencies
- right click on project: Maven->Update project configuration
I guess it was the Update dependencies since right after first two there were no change.
Solution 2
Well, I tried everything posted here, unfortunately nothings works in my case. So, trying different combinations I came out with this one that solved my problem.
1) Open the .classpath file at the root of your eclipse's project.
2) Insert the following entry to the file:
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
Then, rebuild your project at eclipse (Project->Clean-Build).
You now can check at the Java Build Path of you project at the Libraries tab the Maven Dependencies included:
Solution 3
I'm also new to Eclipse, and I've been having a similar problem where Eclipse just won't recognize an import statement, even though all signs point to the dependency having been successfully downloaded.
You should check that your dependency file has actually been downloaded by going to the command line and typing
mvn dependency:tree
If you see your package there, then but Eclipse doesn't acknowledge it, the thing that works for me (sometimes) is to go to the terminal, cd into the project folder, and type
mvn eclipse:clean
then
mvn eclipse:eclipse
Finally refresh project in eclipse
I don't know why this works, and sometimes it doesn't work once, then doing it again does work... so worth a try!
Solution 4
I had this issue for dependencies that were created in other projects. Downloaded thirdparty dependencies showed up fine in the build path, but not a library that I had created.
SOLUTION:
In the project that is not building correctly,
Right-click on the project and choose Properties, and then Maven.
Uncheck the box labeled "Resolve dependencies from Workspace projects"
Hit Apply, and then OK.
Right-click again on your project and do a Maven->Update Snapshots (or Update Dependencies)
And your errors should go away when your project rebuilds (automatically if you have auto-build enabled).
Solution 5
My Project was just screwed up. Here is how I fixed it for Eclipse Indigo x64 (J2EE 3.7.3):
- Deleted my POM file (backedup of course).
- Project Context Menu > Maven > Disable Maven Nature.
- Deleted the project (but not contents on disk).
- Re-imported as Import > General > Existing Project.
- Project Context Menu > Configure > Convert to Maven Project....
- Accept defaults from Maven wizard.
- Overwrite POM with your backedup POM. (Now you have Maven Dependencies folder).
- Maven Update/Clean for good measure.
Hope that helps someone. :)
hostnik
Updated on July 22, 2022Comments
-
hostnik almost 2 years
We have a project set up with maven for resolving dependancies. It usually works fine, but now I am trying to compile and run it on a new PC and I have problem with missing dependencies in Eclipse.
What is funny is that if I run "mvn package" in console or in eclipse, it works fine and even produces war containing all necessary jars. Only Eclipse complains with "The project was not built since its build path is incomplete. Cannot find the class file for org.slf4j.Logger...". If I compare the project with some other computer (where project works fine), I notice that there are quite a few libraries missing under "Maven dependencies" listing in Eclipse. Eventhough they are in the packaged war and they can be found also under repository folder.
So, the jar-s are there just Eclipse won't list them all under "Maven dependencies". What can I do?
Computer is running on Windows 7 with 64bit java & eclipse.
-
Sean Patrick Floyd over 13 yearsProject -> clean usually does the job in cases like this, but sometimes you also have to do
mvn test-compile
(or something similar) on the shell -
hostnik over 13 yearsI know "Project->Clean" and I've tried it, but it didn't help at first.
-
Ranger almost 13 yearsIt was the last point. Update project configuration will add a "Maven Dependencies" library to your project.
-
ngreen almost 12 yearsThis helps me! I don't know what's wrong, but I'm using 64-bit Juno / Springsource 3 and it always fails to import my Maven projects correctly. If I check out as a regular project, rename my POM, then follow your directions from step 5 onward, it works. Otherwise, nothing I try will get the Maven dependencies added to my project aside from command-line
mvn eclipse:eclipse
which is just awful. -
duma almost 10 yearsFYI, I first had to right click on my project, go to Configure and "Convert to Maven project."
-
Anatch over 9 yearsI did this but I still have not the maven dependencies folder. Here is my pom.xml file and I think it is why I have this problem:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>antlr.tuto.calco</groupId> <artifactId>CalculatriceAntlr</artifactId> <version>0.0.1-SNAPSHOT</version> </project>
-
Scott McIntyre over 9 yearsThanks, that resolved my issue. Seems to point to it being an Eclipse bug.
-
evaldeslacasa almost 9 yearsExpanding on Eduard Wirch's answer, I also had to check the "Force Update of Snapshots/Releases" box found at Maven->Update Project... window. My missing artifact was a Snapshot and somehow wasn't updating well without forcing it.
-
Amit Kumar almost 9 yearsThis is the first thing everyone should try. Open the .classpath file that will be in your project directory with notepad and add the lines mentioned and refresh your project.
-
yeaaaahhhh..hamf hamf over 8 yearsThis worked where everything else failed. But do i have to do this for every project i create? Why doesnt it work automatically? What is the real problem?
-
Mat Gessel about 8 yearsSigh, this is still broken in m2e 1.6.2.20150902-002. Tested with a fresh vanilla Eclipse install on Mac OS X / JDK 1.8. Eclipse IDE for Java Developers Version: Mars.2 Release (4.5.2) Build id: 20160218-0600 I wonder if this plugin requires Eclipse Java EE to work properly?
-
DarioBB about 8 yearsHey, there is no such thing as Maven->Update Snapshots (or Update Dependencies). If I go right click, there is no Maven option? Where is located what you described? I'm looking but can't find description after you hit Apply
-
IceBox13 about 8 years@DarioBB This answer is nearly 5 years old. I haven't worked in Eclipse for well over a year. I have no idea if this option is still available or not. I may not be in the most recent version.
-
Manuel Manhart about 8 yearsthis answer should be the first one. The only one which worked ;-) thx
-
Sagar007 over 7 yearsI really dont know where is the problem but I have follow above steps and its working really fine. It causes error like class not found, xml dtd not found. But now it is resolved. Thanks Buddy. Upvote.
-
versvs almost 7 yearsMagic! still valid for Eclipse 4.4.2
-
cjones26 almost 7 yearsThis pointed me in the correct direction by showing me that there were issues with my settings.xml file! Thank you, @rogueleaderr!
-
Zack Zilic over 6 yearsyeah, it worked for my friend, solved all her problems and headaches. Unfortunately didn't work for me.
-
Jack Straw over 6 yearsI had to change the User Settings 'settings.xml' to be the one under my '.m2' directory. It was previously set to one under the Maven install dir.
-
nir over 6 yearsThis messes up workspace in newer version of eclipse. Next time when I open eclipse it gives error in '.metadata' dir and eclipse fails to open.
-
Ivana about 6 yearsThis solution worked for me in Eclipse neon. Do Maven > Update Project (not Update Snapshots) afterwards.
-
Tarun Gupta almost 6 yearsThanks! this solution worked best for me, just one correction tough, I had to close and reopen the project.
-
Tahir Mehmood over 5 yearsWonderful. This worked for me as well. In my project, I couldn't see maven dependencies. Now visible and added to build-path as well. Thanks!
-
user3289695 over 5 yearsIt works, but, why doesn't eclipse do this by itself any longer?
-
Indrajeet Gour almost 5 yearsIt worked for me too but could someone explain what has happen behind the scene??
-
Vanaja Jayaraman over 4 yearsIt worked for me but still the jars are missing. showing with red color cross
-
Bill Naylor over 4 yearsI am running under cygwin, I noticed that only this project was not building under eclipse, though I got successful build (with mvn) on the command line. After running
mvn eclipse:eclipse
all the dependencies were added to the classpath in the eclipse project and the project looked fine. ++ -
NuCradle about 4 yearsThis did it for me. Thanks.
-
chance about 4 yearsThis works for me. What I have inserted to .classpath file is:<br/> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry>
-
Ramaraj Karuppusamy almost 4 yearsWorking for me. Perfect fix.
-
Cromax over 3 yearsKeep in mind that "Project files created with the maven-eclipse-plugin are not supported in M2Eclipse".
-
strash over 3 yearsfinally this worked for me.. all the other answers just wasted my time
-
Abdollah almost 3 yearsWorked well for me!
-
camria almost 3 yearsWhat a pain! Every time I import this project to a new VM I have issues with Eclipse/Maven and I don't think the same solution has worked 3 times. Luckily for me, this one has worked this time. Thanks! I'll add it to my list of possible solutions, which is ever growing :-/
-
camria almost 3 yearsWorth noting: this has removed the Maven nature of my project. So, after the above is done, also right-click on the project -> Configure -> Convert to Maven Project; then, right-click again on the project -> Maven -> Update Project...