Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e56d36f] was not registered for synchronization because synchronization is not active
2023-08-28 12:14:33.528 ERROR 16104 --- [io-7082-exec-40] c.a.druid.pool.DruidAbstractDataSource : discard long time none received connection. , jdbcUrl : jdbc:mysql://localhost:3306/plus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true, jdbcUrl : jdbc:mysql://localhost:3306/plus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true, lastPacketReceivedIdleMillis : 109839
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@1f91efca] will not be managed by Spring
前几天测试以前写的代码的时候报了这么一个错误,虽然不影响运行,但是还是想解决一下
问了别人才知道可能是这两个问题
-
“discard long time none received connection.”:连接池废弃了长时间没有接收到的连接。这可能是因为连接池中的某些连接长时间没有被使用,超过了连接池的闲置时间阈值,连接池会自动将这些连接废弃。
-
“JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@48c25727] will not be managed by Spring”:该JDBC连接由于一些原因,不会被Spring框架管理。
然后我在yml配置中加了这么一条
time-between-eviction-runs-millis: 60000
大致意思是连接池会每隔60秒进行一次空闲连接的检测和回收操作,意思就是自己主动回收了所以不会报自动超时自动回收的错误了
spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/plus?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 1344623216
time-between-eviction-runs-millis: 60000