SqlSession [.....] was not registered for synchronization because synchronization is not active

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

SqlSession [.....] was not registered for synchronization because synchronization is not active_第1张图片

 2.解决办法

 在service方法上加上事务的注解:  @Transactional

再次运行服务,该问题成功解决。

你可能感兴趣的:(springboot,数据库,java,服务器)