问题一:
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e0721ac] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@196918e2] will not be managed by Spring
产生原因:没有配置事物控制
解决办法:在启动类中添加@EnableTransactionManagement 和实现类中添加@Transactional 声明事务就可以了,
本文详细解析了在使用MyBatis框架时遇到的关于SqlSession未注册同步及JDBC连接未被Spring管理的问题。阐述了问题产生的根本原因在于缺少事务控制,并提供了具体的解决方案:在启动类中添加@EnableTransactionManagement注解并结合@Transactional声明事务,从而有效解决了SqlSession的同步和管理问题。
2196

被折叠的 条评论
为什么被折叠?



