SLF4J jar包冲突的迷惑

Running com.cn.ld.modules.jms.JmsTest
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/F:/my_repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/F:/my_repository/org/slf4j/slf4j-nop/1.6.1/slf4j-nop-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.105 sec <<< FAILURE!

是因为在1.6.1版本 slf4j-log4j12 和 slf4j-nop-1.6.1.jar 包含相同的StaticLoggerBinder.class

于是删除slf4j-nop-1.6.1.jar,但是mvn test 提示NoSuchMethodError错误:
-------------------------------------------------------------------------------
Test set: com.cn.ld.modules.jms.JmsTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.111 sec <<< FAILURE!
initializationError(com.cn.ld.modules.jms.JmsTest)  Time elapsed: 0 sec  <<< ERROR!
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
slf4j-api 中 LocationAwareLogger 接口中方法
public abstract void log(Marker marker, String s, int i, String s1,
Object aobj[], Throwable throwable);
对应的字节码为:
public abstract log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V

   添加jcl-over-slf4j 后,测试顺利通过,但是未发现jcl-over-slf4j 有对应的实现方法。
   
    后续解惑.....

你可能感兴趣的:(SLF4J jar包冲突)