使用druid 1.0.0 创建数据库连接,报如下错误
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at com.alibaba.druid.support.logging.SLF4JImpl.info(SLF4JImpl.java:72)at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:638)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:876)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:872)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97)
at com.metasoft.dao.DruidConnectionManager.getConnection(DruidConnectionManager.java:135)
at com.metasoft.dao.DruidConnectionManager.getConnection(DruidConnectionManager.java:198)
以前一直以为是slf4j.api的版本不对,后来查看了源代码,总算发现是druid的日志引用了log4j包,必须添加log4j.jar包才可以。