SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1fa5519] was not registered for synchronization because synchronization is not active


 

 

 

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1fa5519] was not registered for synchronization because synchronization is not active

开发环境:Spring4.3.6 + MyBatis3.4.2 + MySQL5.7
抛出这个提示,不明就里,不知道哪里出现了异常,但是执行到 MyBatis 的 UserDao 中的 saveUser 方法时比较慢,于是将此段代码 try{}catch(),报出如下异常:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error updating database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.DataSourceDisableException
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.DataSourceDisableException

这就明确了问题的症结,是由于 com.alibaba.druid 连接池引起的,由于之前项目中用的 Spring 版本是 3.x 的,本项目用的是 Spring4.x 的,故推测 druid 版本问题,于是将 druid 的版本由 0.2.26 升级为 0.2.26 解决了此问题。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM