baomidou / dynamic-datasource

dynamic datasource for springboot 多数据源 动态数据源 主从分离 读写分离 分布式事务
https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611
Apache License 2.0
4.74k stars 1.19k forks source link

对应版本3.1.0,springboot2.1.0.RELEASE,项目启动报错 #272

Closed Fation-Ren closed 4 years ago

Fation-Ren commented 4 years ago

Enviroment

JDK Version(required): 1.8

SpringBoot Version(required): 2.1.0.RELEASE

dynamic-datasource-spring-boot-starter Version(required): 3.1.0

druid Version(optional):

Describe

项目启动报错 Expected Result: 。。。 Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger at com.alibaba.druid.filter.logging.Log4jFilter.<init>(Log4jFilter.java:26) ~[druid-1.1.22.jar:1.1.22] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_181] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_181] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_181] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_181] at java.lang.Class.newInstance(Class.java:442) ~[na:1.8.0_181] at com.alibaba.druid.filter.FilterManager.loadFilter(FilterManager.java:124) ~[druid-1.1.22.jar:1.1.22] at com.alibaba.druid.pool.DruidAbstractDataSource.addFilters(DruidAbstractDataSource.java:1365) ~[druid-1.1.22.jar:1.1.22] at com.alibaba.druid.pool.DruidAbstractDataSource.setFilters(DruidAbstractDataSource.java:1354) ~[druid-1.1.22.jar:1.1.22] at com.alibaba.druid.pool.DruidDataSource.configFromPropety(DruidDataSource.java:274) ~[druid-1.1.22.jar:1.1.22] at com.baomidou.dynamic.datasource.creator.DruidDataSourceCreator.createDataSource(DruidDataSourceCreator.java:95) ~[dynamic-datasource-spring-boot-starter-3.1.0.jar:3.1.0] at com.baomidou.dynamic.datasource.creator.DataSourceCreator.createDruidDataSource(DataSourceCreator.java:148) ~[dynamic-datasource-spring-boot-starter-3.1.0.jar:3.1.0] at com.baomidou.dynamic.datasource.creator.DataSourceCreator.createDataSource(DataSourceCreator.java:90) ~[dynamic-datasource-spring-boot-starter-3.1.0.jar:3.1.0] at com.baomidou.dynamic.datasource.provider.AbstractDataSourceProvider.createDataSourceMap(AbstractDataSourceProvider.java:44) ~[dynamic-datasource-spring-boot-starter-3.1.0.jar:3.1.0] at com.baomidou.dynamic.datasource.provider.YmlDynamicDataSourceProvider.loadDataSources(YmlDynamicDataSourceProvider.java:42) ~[dynamic-datasource-spring-boot-starter-3.1.0.jar:3.1.0] at com.baomidou.dynamic.datasource.DynamicRoutingDataSource.afterPropertiesSet(DynamicRoutingDataSource.java:254) ~[dynamic-datasource-spring-boot-starter-3.1.0.jar:3.1.0] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE] ... 150 common frames omitted Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_181] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_181] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_181] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_181]

Actual Result:
需要额外引入log4j包才可以正常启动 `

log4j
        <artifactId>log4j</artifactId>
    </dependency>`

Steps to reproduce

huayanYu commented 4 years ago

你如果设置了Log4j的filter肯定需要手动加, 无论如何和我数据源无关。 只是你的配置问题

Fation-Ren commented 4 years ago

的确,配置中,druid监控里面,多了log4j的filter,谢谢