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