Missing Maven dependencies in an Eclipse project

We have a project created with maven to resolve dependencies. It usually works fine, but now I'm trying to compile and run it on a new PC, and I have a problem with missing dependencies in Eclipse.

It's funny that if I run the "mvn package" in the console or in eclipse, it works fine and even produces a war containing all the necessary banks. Only Eclipse complains about "The project was not built because its build path is incomplete. Cannot find the class file for org.slf4j.Logger ...". If I compare the project with some other computer (where the project works fine), I notice that there are many libraries in the "Maven Dependencies" section in Eclipse. Despite being in a packaged war, they can also be found in the repository folder.

So, in jar-s there are only Eclipse that will not list them in the "Maven Dependencies" section. What can I do?

The computer runs on Windows 7 with 64-bit java and eclipse.

+80
eclipse maven-2 m2eclipse
Nov 23 '10 at 23:40
source share
28 answers

The problem is solved!

I don’t know what exactly decided, but I did 4 things in Eclipse:

  • Window-> Settings: Maven-> Preferences: Global settings → open file and hard-coded localRepository
  • Project-> Clean
  • right click on the project: Maven-> Update Dependencies
  • right click on the project: Maven-> Update project configuration

I assume these were Update dependencies, since there were no changes right after the first two.

+65
Nov 24 2018-10-10T00:
source share

Well, I tried everything that was here, unfortunately, nothing works in my case. Therefore, trying all kinds of combinations, I came up with this problem, which solved my problem.

1) Open the .classpath file in the root of your eclipse project.

2) Insert the following entry into 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 the project in eclipse (Project-> Clean-Build). Now you can check your project’s Java Build Path on the Libraries tab, which includes Maven dependencies: enter image description here

+73
Dec 6 '14 at 21:59
source share

I am also new to Eclipse, and I had a similar problem where Eclipse simply does not recognize the import statement, although all the signs indicate that dependencies were loaded successfully.

You should check if your dependency file is really loaded by going to the command line and typing

mvn dependency:tree

If you see your package there, but Eclipse does not recognize it, then what works for me (sometimes) is to go to the terminal, cd to the project folder and enter

mvn eclipse:clean then mvn eclipse:eclipse

Finally update the project in eclipse

I don’t know why this works, and sometimes it doesn’t work once, and then re-doing the work ... so worth a try!

+26
Dec 27 '11 at 4:55
source share

My project was just ruined. Here is how I fixed it for Eclipse Indigo x64 (J2EE 3.7.3):

  • Deleted my POM file (of course, supported).
  • Project Context Menu > Maven > Disable Maven Nature .
  • The project is deleted (but not the contents on the disk).
  • Re-imported as Import > General > Existing project .
  • Project context menu > Configure > Convert to Maven ... project .
  • Accept the default settings from the Maven wizard.
  • Overwrite POM with POM support. (Now you have the Maven Dependencies folder).
  • Maven update / cleanup for a good measure.

Hope this helps someone. :)

+25
Mar 18 '12 at 19:50
source share

I had this problem for dependencies created in other projects. The loaded thirdparty dependencies showed up in the build path, but not in the library I created.

SOLUTION: In a project that is not building correctly,

  • Right-click the project and select Properties and then Maven.

  • Uncheck the box " Allow dependencies from workspace projects "

  • Click Apply, and then OK.

  • Right click on your project and do Maven-> Update Snapshots (or Update Dependencies)

And your mistakes should go away when your project is rebuilt (automatically, if automatic assembly is enabled).

+19
Aug 02 2018-11-11T00:
source share

Just in case, someone tried all the other parameters, and you are still stuck, try right-clicking on the project folder, go to the Maven option and click the "add dependency" button. For some reason, Eclipse does not manually update dependencies from pom.xml on the first try.

screen shot of menu selection

+6
Jan 6 '16 at 13:34
source share

So, I'm late for this party for 4-5 years, but I had this problem after exiting our repo, and none of the other solutions to this topic were developed in my case to get rid of these warnings / errors.

This worked for me:

From Eclipse, go to Window -> Preferences -> Maven (expand) -> Errors / Warnings. The last option reads: “The execution of the plugins is not covered by the life cycle configuration” - use the drop-down menu for this option and select “Ignore”, then “Apply”, then “OK”. (In the "Maven Projects Upgrade Required" field, enter "OK.")

Additional Information:

This may not necessarily “fix” the underlying problems and may not qualify as “best practice” for some, however it should remove / prevent these warnings from appearing in Eclipse and allow you to move forward at least. In particular, I worked with Eclipse Luna Service Release 1 (4.4.1) w / Spring Dashboard and Spring IDE Core (3.6.3) and installed m2e (1.5), running on Arch Linux and OpenJDK 1.7. I imported my project as an existing maven project and selected OK when I was warned about existing warnings / errors (to solve them later).

Suppress / Remove "Plugin Execution not covered ..." warnings Eclipse-Maven

(Sorry, I'm not a designer, but added clarity.)

+4
Jan 20 '15 at 14:29
source share

In the following case, we performed the following steps:

1 On an eclipse, right-click on the desired Maven project → Disable Maven Nature

2 Right-click again, then go to Properties . Remove all evidence of Maven's external dependency, leaving only the JRE System Library.

3 Right-click again on the project, then go to Configure → Convert to Maven Project

+4
Apr 08 '16 at 12:36
source share

I had a similar problem. I solved this by doing the Maven-> Update Project Configuration action

+3
Jun 22 '12 at 19:34
source share

None of the above solutions worked for me, so this answer is for someone else in my situation. In the end, I myself found the problem and another solution. The pom.xml file contained a dependency tag that recruited dependencies, and M2Eclipse does not add the Maven Dependencies folder when it was present. So, I removed this tag, then executed the solution proposed by Ualter Jr., and Eclipse immediately added the missing folder!

+3
Feb 25 '15 at 9:44
source share

For me, the problem was that maven could not find the settings.xml file, which is located in myMavenFolder \ conf .

What I did to fix the problem was to select the correct location of the settings.xml file from eclipse:
Window -> Preferences -> Maven -> User Preferences

Finally, click apply and update your project.

+3
Aug 20 '15 at 7:50
source share

Well, I tried everything that was here, unfortunately, nothing works in my case. Therefore, trying all kinds of combinations, I came up with this problem, which solved my problem.

1) Open the .classpath file in the root of your eclipse project.

2) Insert the following entry into 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 the project in eclipse (Project-> Clean-Build).

+2
Dec 6
source share

If you have errors of "nested paths" after executing Maven → Update project configuration (or in Juno it is "Update configuration ..."), then your build path is incorrectly configured.

Right-click the project → Build Path → Configure Build Path

Make sure that only '/ src' and directories at this level are included. If you have, for example, '/ src' as well as '/ src / main / resources', this is not true. The second resource ('/ src / main / resources') is “nested” under the first (“/ src”), which makes it impossible to import resources, since it does not allow eclipse to see maven dependencies.

+1
Aug 09 2018-12-12T00:
source share

My problem sounds similar, so I will add to the discussion. I canceled the import of an existing maven project into Eclipse, as a result of which they were not allowed to update and would not be able to finish building the workspace.

What I needed to do to resolve this was select Run As... -> Maven build... and in the Goals I section, introduced dependency:go-offline , and started it.

Then I right-clicked the project and selected Maven -> Update Project... and updated that specific project.

This allowed you to create the source folders and complete the import.

+1
Oct 18 :
source share

I could solve the error 1) Right click (your maven project) -> maven -> maven install

After successful installation

2) Right click (your maven project) -> maven -> update project. And all maven error has been resolved!

+1
Oct 20 '13 at
source share

It was enough for me to add buildCommand (org.eclipse.m2e.core.maven2Builder) and nature (org.eclipse.m2e.core.maven2Nature) in the .project file, for example:

 <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>iText</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.m2e.core.maven2Builder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature> </natures> </projectDescription> 

and I enter image description here

+1
Feb 03 '15 at 8:02
source share

That's how I solved it

  • Window-> Settings: Maven-> User Settings (click "open file" in the window that appears, or simply edit the settings.xml file using an external text editor such as Notepad) Make sure the localRepository (which appears in this window) is correct. I had a typo in my file.
  • After you have adjusted the settings.xml, click "Update Settings", which is located on the same screen "Settings → Maven-> User Settings".

Now rebuild, and he will install the last JAR in the right place.

+1
Jun 25 '15 at 23:39
source share

I had a similar problem and tried to answer all the questions in this post. Closest I came to a solution to this problem, combining the solutions of Joseph Lust and Paul Crease. I added a backup pom.xml file after deleting and re-importing the project, and nothing appeared until I removed the dependency management tag in pom.xml, and, like magic, the dependency folder was there.

However, it crashed the child POM, because they needed the dependency management of the parent pom.xml to work, and as a result, my MVN did not work properly in the project either from Eclipse or from the command line, giving a broken pom. xml.

The final solution, if all else fails, is to manually import the .jar files your project needs. Right-click the Properties project → Java Build Path → Libraries and Add External Banner.

If MVN works correctly from the command line and you successfully completed the project, you will have all the repositories needed in your .m2 / repository folder. Add all the external jars mentioned in your pom.xml dependency tag and you will see the help library section in your Eclipse, with all the nasty red errors gone.

This is not an optimal solution, but it allows you to work in Eclipse without any errors of missing dependencies, and also allows you to create a Maven project both from Eclipse and from the command line.

+1
Apr 03 '16 at 20:21
source share

The same problem happened to me, and it happened due to an error loading the jar due to problems with the repo indicated by the red flag in pom.xml .

I added another repository, so the red flag in pom.xml disappeared, and Eclipse loaded pom again, resolved its problem, and listed the maven dependencies in Project Explorer. this sounds simple and obvious for solving visible problems, but since Eclipse was very happy to launch maven and worked successfully, it was not obvious that the red flag and repo problem were fundamentally due to its unwillingness to parse pom and list maven dependencies

+1
Oct 13 '16 at 10:39
source share
 mvn eclipse:clean 

then from the eclipse: "Maven Upgrade Project" does the trick!

+1
Feb 12 '17 at 20:33
source share

update .classpath below will work every time.

 <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" output="target/classes" path="src/main/java"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry kind="src" output="target/test-classes" path="src/test/java"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> <classpathentry excluding="WEB-INF/" kind="src" path="src/main/webapp"/> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <attributes> <attribute name="maven.pomderived" value="true"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="target/classes"/> </classpath> 
+1
Jun 12 '17 at 1:31 on
source share

It is so amazing that this one problem has so many different causes and possible solutions. I found another solution that worked for me.

Well, this is not so much a solution as a discovery: I see the Maven Dependencies node in the package explorer, which is used by default for the Java perspective, but I do not see it in the Java EE perspective, which Project Explorer uses by default. Both of these researchers look very much like a peek, so you can expect to see Maven dependencies in both.

As I tried to understand this, I did not realize this difference, so in the end it was not a problem for me.

0
Oct 23 '12 at 19:59
source share

the whole project looked strange in eclipse, the maven dependency folder was missing, it showed some types as unknown, but I was able to build it successfully in maven. Fixed the problem with adding the gen folder to the source path on the path to building the project.

It probably looks like this Android / FBReaderJ / gen already exists, but is not the source folder. Convert to rename folder or rename it

0
Aug 28 '13 at 10:28
source share

In Eclipse STS, if "Maven Dependencies" disappears, you should check and fix your pom.xml . I did it (twice) and I solved it. This was not a dependency problem, but a string generated and randomly moved in my pom.xml .

0
Feb 03 '17 at 2:36 on
source share

In the following case, we performed the following steps:

1 On an eclipse, right-click on the desired Maven project → Disable Maven Nature

2 Right-click again, then go to the "Properties" menu. Remove all evidence of Maven's external dependency, leaving only the JRE System Library.

3 Right-click again on the project, then go to "Configure" → "Convert to Maven Project"

he worked for me also

0
Jun 07 '17 at 13:14
source share

My answer is similar to @JerylCook's: find another .classpath file in the Maven working project, edit your bad ones as good working ones. The key is to add

 <attributes> <attribute name="maven.pomderived" value="true"/> </attributes> 

in each <classpathentry> type con and src . Remember to change <classpathentry .... /> to <classpathentry ...>xxx</classpathentry> .

Finally, upgrade your maven project and reinstall / rebuild in maven.

0
Sep 12 '17 at 14:52
source share

All of the above did not work with me. The only fix was deleting the repository folder in .m2 and then updating maven from eclipse.

0
Sep 20 '17 at 15:26
source share

How many answers. You see, there can be many reasons why this does not work, as expected. In my case, I was also not aware of the tag around my dependencies. Facepalm

Example:

 ... <dependencyManagement> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${org.slf4j.version}</version> </dependency> </dependencies> </dependencyManagement> 

this only DEFINITES the dependency for this and all subprojects with the correct version! This is what it, for example, should look like in a POM master. To really use lib in this current project, you also add a parameter as follows:

 ... <dependencyManagement> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${org.slf4j.version}</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </dependency> </dependencies> 

NOW it will provide lib in this current project.

0
Feb 13 '18 at 8:21
source share



All Articles