微服务项目排错: DruidDataSourceAutoConfigure Init DruidDruidDataSource

Posted licbc

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微服务项目排错: DruidDataSourceAutoConfigure Init DruidDruidDataSource相关的知识,希望对你有一定的参考价值。

文章记录项目报错排查过程:

问题描述:项目架构 spring cloud alibaba ,其中一服务启动时一直卡在 Init DruidDataSource,且在不停地打印INFO级别的 " Init DruidDataSource"

 [main] INFO  c.a.d.s.b.a.DruidDataSourceAutoConfigure:56 - Init DruidDataSource
 [main] INFO  c.a.d.s.b.a.DruidDataSourceAutoConfigure:56 - Init DruidDataSource
 [main] INFO  c.a.d.s.b.a.DruidDataSourceAutoConfigure:56 - Init DruidDataSource
 ....

修改logback.xml日志配置文件,修改为DEBUG级别,打印更多详细日志

发现一在个DEBUG级别的日志中隐藏着Bean创建错误如下:

2021-06-08 17:05:18.896 [main] INFO  o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker:335 - Bean 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-06-08 17:05:18.913 [main] DEBUG o.s.b.factory.support.DefaultListableBeanFactory:1665 - Bean creation exception on eager FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jimuReportShareDao' defined in URL [jar:file:/C:/Users/admin/.m2/repository/org/jeecgframework/jimureport/spring-boot-starter-jimureport/1.3.1-beta4/spring-boot-starter-jimureport-1.3.1-beta4.jar!/org/jeecg/modules/jmreport/desreport/dao/JimuReportShareDao.class]: Cannot create inner bean '(inner bean)#430212cb' of type [org.jeecgframework.minidao.aop.MiniDaoHandler] while setting bean property 'proxy'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#430212cb#9': Unsatisfied dependency expressed through field 'jdbcTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jdbcTemplate' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/JdbcTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

主要异常堆栈最后一个报错当作根本原因: Failed to determine a suitable driver class

目测应该是Jar冲突,打开IDEA的项目JAR依赖视图

果然发现有两个版本不同的mysql jar

接下自然就想到用maven 的 dependeny:tree 目标打印依赖关系
打印报错服务的依赖视频后,经验检查并没有发现有8.0.21的包,推测可能是和其它服务或parent项目的依赖有冲突,对顶级项目执行 dependeny:tree

+- org.jeecgframework.boot:jeecg-boot-base-tools:jar:2.4.3:compile
+- mysql:mysql-connector-java:jar:8.0.21:runtime

+- org.springframework.boot:spring-boot-starter-web:jar:2.3.5.RELEASE:compile
+- mysql:mysql-connector-java:jar:8.0.22:runtime

发项顶级项目中配置了:
<mysql-connector-java.version>8.0.21</mysql-connector-java.version>

故修改pom.xml配置的版本号,重新构建,问题解决

以上是关于微服务项目排错: DruidDataSourceAutoConfigure Init DruidDruidDataSource的主要内容,如果未能解决你的问题,请参考以下文章

微服务项目排错: DruidDataSourceAutoConfigure Init DruidDruidDataSource

抓包排错-tcp.flags.reset

Linux7/Centos7grub配置文件及排错

Debian 打开SSH服务以及SSH基本排错方法

报错来了不要崩!nginx服务启动失败排错分析!

第198天学习打卡(谷粒商城 项目 排错)