1.报错信息
今天运行服务,多线程插入数据库操作的时候(程序运行正常),发现控制台有如下提示信息:
will not be managed by Spring
报错信息如下:
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3650604c] was not registered for synchronization because synchronization is not active
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@26686f3e] was not registered for synchronization because synchronization is not active
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7468ffee] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@334852565 wrapping org.postgresql.jdbc.PgConnection@1b26fac2] will not be managed by Spring
JDBC Connection [HikariProxyConnection@1897592623 wrapping org.postgresql.jdbc.PgConnection@7980cb0f] will not be managed by Spring
2.解决办法
在service方法上加上事务的注解: @Transactional文章来源:https://www.toymoban.com/news/detail-734628.html
再次运行服务,该问题成功解决。文章来源地址https://www.toymoban.com/news/detail-734628.html
到了这里,关于SqlSession [.....] was not registered for synchronization because synchronization is not active的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!