https://www.jianshu.com/p/217017b2e73d
SpringBoot配置数据库连接池,但日志却每次都新建连接
Mybatis中动态打印SQL语句到控制台,只需要在SpringBoot配置文件中添加如下配置即可
mybatis:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
但是如果没有用到任何连接池的话,是不会打印的
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2a5ca7d7] was not
registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@9a51d74] will not be managed by Spring
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2a5ca7d7]
解决方法:
确保有可用的连接池被使用,引入第三方连接池要做好配置
本人不是很明白这个意思