项目启动报错
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]
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包才可以正常启动 `
Steps to reproduce
Step 1 引入dynamic-datasource-spring-boot-starter
Step 2 设置动态切换
Step 3 项目启动