1

I get the following warnings in my Maven build:

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/ralph/.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:/C:/Users/ralph/files/software/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:/C:/Users/ralph/.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:/C:/Users/ralph/files/software/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]

I look for explanations and find that I must have a dependency that includes a transient dependency on slf4j. So I generate a dependency tree and find, among everything else, the following lines:

...
[INFO] +- net.sourceforge.tess4j:tess4j:jar:4.4.1:compile
[INFO] |  +- net.java.dev.jna:jna:jar:5.4.0:compile
[INFO] |  +- com.github.jai-imageio:jai-imageio-core:jar:1.4.0:compile
[INFO] |  +- org.ghost4j:ghost4j:jar:1.0.1:compile
[INFO] |  |  +- log4j:log4j:jar:1.2.17:compile
[INFO] |  |  +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
...
[INFO] |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  +- org.slf4j:jul-to-slf4j:jar:1.7.28:compile
[INFO] |  +- org.slf4j:jcl-over-slf4j:jar:1.7.28:compile
[INFO] |  \- org.slf4j:log4j-over-slf4j:jar:1.7.28:compile

(The lower dependencies in the tree are still within those belonging to tess4j.)

My problem is that I don't know how to translate that to one or more exclusion tags to eliminate the warning message. I tried:

<dependency>
    <groupId>net.sourceforge.tess4j</groupId>
    <artifactId>tess4j</artifactId>
    <version>4.4.1</version>
    <exclusions>
        <exclusion>
            <artifactId>log4j</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>

but it didn't have any effect. How do I translate the information from the dependency tree into an exclusion to get rid of my warning message?

arcy
  • 12,845
  • 12
  • 58
  • 103
  • 2
    Does this help : https://stackoverflow.com/questions/63518376/eclipse-maven-slf4j-class-path-contains-multiple-slf4j-bindings ? – Baptiste Beauvais Apr 17 '22 at 13:13
  • Well, that got rid of the warnings I had. Now I have a different one -- when I start up eclipse, it tells me the "optional" slf4j package is required or some such. I'll look into that later. Thanks. – arcy Apr 17 '22 at 13:34

0 Answers0