Got a problem getting slf4j working for me with m2e. This is not the first time to state this problem. However, others have a more specific case and still no answer.
I installed Eclipse-jee fresh. For test I created a simplest maven project from maven-archetype-quickstart. It simply prints out Hello World!
Although applying m2e it compiles and runs fine, I get the messages in red
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/rschumacher/install/eclipse-jee/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/rschumacher/install/eclipse-jee/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]
This happens with any maven project when performing run as/Maven test.
It doesn't help to look at the dependency:tree of the pom.xml, as the conflicting bindings are with m2e and osgi (as far as I can interprete the messages).
As result, slf4j ignores the configuration and is no longer usable from within Eclipse with m2e installed.
If I start mvn test from a commandline, no such messages appear. slf4j logging is working as it should.
Do you got any idea or workaround in order to have slf4j working again with m2e?
If you are looking for quick solution for this issue, you need to find out how log4j is present on your path. run mvn dependency:tree and figure out the maven dependency and exclude log4j with snippet below to that dependency in your pom. xml . This should resolve SLF4J: Class Path Contains Multiple SLF4J Bindings.
Bindings are basically implementations of a particular SLF4J class meant to be extended to plug in a specific logging framework. By design, SLF4J will only bind with one logging framework at a time. Consequently, if more than one binding is present on the classpath, it will emit a warning.
With the help of Nickel Cao's answer, I was (eventually) able to fix the SLF4J error/warning messages you are describing. However, Nickel's solution only fixed the default Maven Run As goals. My custom Maven build goals - the only goals I ever use - also had to be updated before the SLF4J errors went away.
NOTE: I fixed the problem in Eclipse 2020-09, not 2020-06.
Here's how I did it, with some screenshots. (Sorry, I don't have the reputation to embed them.)
Once I had performed this last step, my custom Run-As Maven builds stopped generating the SLF4J errors: Screenshot of victory
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With