alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.97k stars 8.58k forks source link

spring-boot3+druid1.2.22+mybatis-plus3.5.6出错,回退druid1.2.21没问题 #5917

Open 4innocent opened 6 months ago

4innocent commented 6 months ago

Spring Boot Version: 3.2.5

19:04:33.311 [restartedMain] INFO c.e.c.m.Application - [logStarting,50] - Starting Application using Java 17.0.6 with PID 104932
19:04:33.314 [restartedMain] DEBUG c.e.c.m.Application - [logStarting,51] - Running with Spring Boot v3.2.5, Spring v6.1.6
19:04:33.315 [restartedMain] INFO c.e.c.m.Application - [logStartupProfileInfo,660] - The following 1 profile is active: "test"
19:04:35.792 [restartedMain] INFO o.a.c.h.Http11NioProtocol - [log,173] - Initializing ProtocolHandler ["http-nio-8190"]
19:04:35.793 [restartedMain] INFO o.a.c.c.StandardService - [log,173] - Starting service [Tomcat]
19:04:35.794 [restartedMain] INFO o.a.c.c.StandardEngine - [log,173] - Starting Servlet engine: [Apache Tomcat/10.1.20]
19:04:35.863 [restartedMain] INFO o.a.c.c.C.[.[.[/] - [log,173] - Initializing Spring embedded WebApplicationContext
19:04:36.439 [restartedMain] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - [refresh,632] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cmFlowMapper' defined in file [mapservice\system\mapper\CmFlowMapper.class]: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
Caused by: java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required
at org.springframework.util.Assert.notNull(Assert.java:172)
at org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:125)
at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1833)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
... 63 common frames omitted
4innocent commented 6 months ago

datasource:
   type: com.alibaba.druid.pool.DruidDataSource
   driverClassName: oracle.jdbc.OracleDriver
   url:
   username: 
   password: 
   druid:
     # 初始连接数
     initialSize: 5
     # 最小连接池数量
     minIdle: 10
     # 最大连接池数量
     maxActive: 20
     # 配置获取连接等待超时的时间
     maxWait: 60000
     # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
     timeBetweenEvictionRunsMillis: 60000
     # 配置一个连接在池中最小生存的时间,单位是毫秒
     minEvictableIdleTimeMillis: 300000
     # 配置一个连接在池中最大生存的时间,单位是毫秒
     maxEvictableIdleTimeMillis: 900000
     # 配置检测连接是否有效
     validationQuery: SELECT 1 FROM DUAL
     testWhileIdle: true
     testOnBorrow: false
     testOnReturn: false
     webStatFilter:
         enabled: true
     statViewServlet:
         enabled: false
         # 设置白名单,不填则允许所有访问
         allow:
         url-pattern: /druid/*
         # 控制台管理用户名和密码
         login-username:
         login-password:
     filter:
         stat:
             enabled: true
             # 慢SQL记录
             log-slow-sql: true
             slow-sql-millis: 1000
             merge-sql: true
         wall:
             config:
                 multi-statement-allow: true
zrlw commented 5 months ago

druid1.2.22配置的连接超时参数默认取自jdbc url的connectTimeout和socketTimeout,不过这个改动貌似和你的问题没关系。 你贴的堆栈信息是创建datasource失败了,但原因不明。 建议你的springboot应用配置里加debug: ture (yml) 或 debug=true(properties格式),然后命令行上启动一下,把控制台显示的内容全部收集一下才能进一步判断。

zrlw commented 5 months ago

可试试@lizongbo 在 #5783 的建议:

调整一下配置,使用springboot的DataSourceProperties对应的这些变量名进行配置即可
zrlw commented 5 months ago

另外druid-spring-boot-3-starter修订了之前版本存在的缺陷,但相关代码仍存在兼容问题,如 #5785 @lizongbo 已经做了修改,只是要等到下一个版本了。

4innocent commented 5 months ago

好的,新版本发布了我再试下