13

I got this error when trying to run as Maven Build. Could someone please help me resolve the binding conflicts, thanks.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
Zhe
  • 131
  • 1
  • 1
  • 3

6 Answers6

19

This is not a bug in eclipse. We just have to uninstall the slf4j from "Maven integration for eclipse" which is an additional software already installed on the eclipse. You can see this in eclipse market place.

Do the below steps:

  1. In eclipse, Go to help -> click on Market place -> click on installed. Here you will see the Maven integration for eclipse which is already installed. enter image description here
  2. Now click on change button. There you will see slf4j over logback is checked. Uncheck it and click on confirm button. This will uninstall the slf4j from "Maven integration for eclipse" software. enter image description here

Now you can check that the slf4j binding error is gone when you do the maven build. Enjoy!

Sagar Salokhe
  • 276
  • 3
  • 7
  • 6
    Perfect. One trick is that 'Market place -> click on installed' is not displaying 'Maven integration for Eclipse'. So I did a search on 'Maven integration for Eclipse' which displayed as 'Installed'. Then choose to change as you suggested in screen shot. FYI. I used Eclipse version 2020-12. – Krishna Apr 01 '21 at 07:21
  • Eclipse SYMREL 2021-06: Same idea, different method: Help -> About Eclipse IDE -> Installation Details - Select slf4j over logback and then Uninstall. Just using a external Maven did not help. – Jonathan Rosenne Aug 13 '21 at 18:55
  • I am using Eclipse 2021-03 and I dont have Maven Integration installed and still having same problem. – pixel Oct 04 '21 at 21:29
  • If the maven integration is not available in install search for that, you will see it's showing installed. Click on on installed and it will show in installed plugins list. Then you can follow above steps. Note : Eclipse 2021-09 – Dilip Meghwal Nov 01 '21 at 04:45
7

This is a known bug in Eclipse. A workaround is, that you install Maven separately (not using the Eclipse-embedded Maven binary).

Then you can chose that external Maven binary under: Window->Preferences->Maven->Installations

It should look like this: enter image description here

I'm using Windows here but in Linux it's the same procedure. Install maven from your package manager (e.g. sudo apt install maven), then activate it in Eclipse.

P.S: After you've installed Maven on your system, the command mvn dependency:tree will also work.

m4110c
  • 427
  • 4
  • 10
  • I tried using external maven, but note on the screen above that the embedded runtime is used for dependency resolution, and that's when the conflict occurs. I still get the eror. – Randy Avis Dec 18 '20 at 20:26
5

This seems to be a bug in Eclipse up to version 2020-09. I got this as well.

Cf. https://bugs.eclipse.org/bugs/show_bug.cgi?id=506676.

No work around that I know of so far. Working with Maven dependencies of your project won't solve the problem since it is caused by the m2e plugin and eclipse, so it's beyond the scope of your project, it's inside the IDE. :-(

  • Thanks, so the best option is to choose older version of Eclipse? – Zhe Sep 26 '20 at 10:12
  • 1
    I can't tell what your best option could be, because it depends on your requirements. For example: I chose to ignore the warning since I cannot go back to an older version of Eclipse without other drawbacks which would be worse. – Christoph Andriessens Sep 28 '20 at 06:47
1

I would suggest using the Maven dependency tree plugin. Run the following from the root level of your project, where your pom.xml file sits:

mvn dependency:tree

You may do a search/grep on the output for slf4j to see which libraries are bringing in an slf4j dependency, and what version(s) are being brought in. It is also possible to further restrict the output from the command line, using GAV coordinates. However, I often find it useful to see the entire tree, if for no other reason than I can be certain that I am seeing every dependency in my project. If you can get this far, you are about halfway done.

The next step is what to do about the dependencies which are bringing in the unwanted slf4j transitive dependenc(ies). You may follow this Stack Overflow question and exclude slf4j from these dependencies, using something looking like this in your POM file:

<dependency>
    <groupId>com.example</groupId>
    <artifactId>foo-bar</artifactId>
    <version>1.2.3</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

You may have to add multiple exclusions to remove all but the one slf4j dependency you really want to include. As a sanity check, you may run depedency tree again, to verify that you only have one implementation in your build.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Thanks for helping, one more question that how to make the mvn dependency:tree running? – Zhe Aug 22 '20 at 01:08
  • I don't understand your comment above. – Tim Biegeleisen Aug 22 '20 at 01:51
  • ```mvn dependency:tree``` not sure where to put this command – Zhe Aug 22 '20 at 02:48
  • You need to run this from the command line. Some IDEs, such as IntelliJ, also have an option for running command line Maven commands. – Tim Biegeleisen Aug 22 '20 at 03:14
  • Ok, thanks, as I run this command and it show ```zsh: command not found: mvn``` – Zhe Aug 23 '20 at 02:16
  • This command is only usable if you have an external Maven installation on your system. I guess you're using the internal installation, that comes with Eclipse/IntelliJ IDE. In Eclipse you can open your pom.xml and look for a tab called "Dependency Hierarchy" under the text editor window. – m4110c Sep 28 '20 at 11:58
  • Using mvn dependency:tree is not helping nor the Dependency Hierarchy tab in Eclipse pom view. – pixel Oct 04 '21 at 21:40
0

In case there is any question as the the cause, run maven from the command line for the project (i.e. mvn clean package). You will not see the error. As Christoph Andriessens said, it's in the IDE.

Randy Avis
  • 75
  • 9
0

This Bug is known in eclipse since 2016:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=506676

Nothing has changed for more than five years.

Bernt
  • 11
  • 1