0

Right after installation I created project from maven-archetype-quickstart and start dependency:tree goal. Here is output in Eclipse console:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/anahel/.p2/pool/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:/Users/anahel/Documents/Apps/eclipse/ee/jee-2020-12/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:/Users/anahel/.p2/pool/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:/Users/anahel/Documents/Apps/eclipse/ee/jee-2020-12/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]
[INFO] Scanning for projects...
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.5.2/maven-install-plugin-2.5.2.pom
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.5.2/maven-install-plugin-2.5.2.pom (6.4 kB at 2.1 kB/s)
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/25/maven-plugins-25.pom
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/25/maven-plugins-25.pom (9.6 kB at 14 kB/s)
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.8.2/maven-deploy-plugin-2.8.2.pom
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.8.2/maven-deploy-plugin-2.8.2.pom (7.1 kB at 12 kB/s)
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.7.1/maven-site-plugin-3.7.1.pom
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-site-plugin/3.7.1/maven-site-plugin-3.7.1.pom (19 kB at 31 kB/s)
[INFO] 
[INFO] -------------------------< me.anahel:deleteme >-------------------------
[INFO] Building deleteme 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ deleteme ---
[INFO] me.anahel:deleteme:jar:0.0.1-SNAPSHOT
[INFO] \- junit:junit:jar:4.11:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.330 s
[INFO] Finished at: 2021-02-21T01:59:50+10:00
[INFO] ------------------------------------------------------------------------

How to fix "SLF4J: Class path contains multiple SLF4J bindings." in my case?

teXI
  • 51
  • 9
  • See https://stackoverflow.com/a/66231810/6505250 – howlger Feb 20 '21 at 16:07
  • @howlger what can I do? In Intellij IDEA there no such warnings... – teXI Feb 20 '21 at 16:12
  • Ignore it and/or provide a patch. I don't see this in the current Eclipse (in the _Console_ view?), so providing a [minimal reproducible example `pom.xml`](https://stackoverflow.com/help/minimal-reproducible-example) would be a good start. – howlger Feb 20 '21 at 16:32
  • @howlger minimal reproducible example - run verify goal on maven-archetype-quickstart like "Run As..."-"Maven build..." in Jave Enterprise Edition 2020-12 – teXI Feb 20 '21 at 16:37
  • Also in the _Eclipse IDE for Java Developers_? – howlger Feb 20 '21 at 17:00
  • Looks like any installation with both `org.eclipse.osgi` and `org.eclipse.m2e.maven.runtime.slf4j.simple`. – nitind Feb 20 '21 at 17:21
  • @MarkRotteveel See first comment – howlger Feb 20 '21 at 19:52
  • @howlger Ah, I hadn't followed that link, so I hadn't seen they were the same, and I had run out of close votes. – Mark Rotteveel Feb 20 '21 at 21:01

1 Answers1

0

First you need to find offending package containing these 'extra' packages. You can do so by running the following cmd from CLI mvn dependency:tree. This will output the dependency tree.

Once you know which module contains these SLF4J packages just exclude them in your pom config like so

<dependency>
    <groupId>package1</groupId>
    <artifactId>package1</artifactId>
    <version>${package1.version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-id</artifactId>
        </exclusion>
        <exclusion>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>

That should do :)

Edit:

In the output you can see the following

SLF4J: Found binding in [jar:file:/Users/anahel/.p2/pool/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:/Users/anahel/Documents/Apps/eclipse/ee/jee-2020-12/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]

So you have 1 class inside your .p2 pool for eclipse m2e plugin and another class inside your eclipse/ee directory.

Maciej Cygan
  • 5,351
  • 5
  • 38
  • 72