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 解決了此問題。
