mybatis整合 遇见的问题

  1. 当sql连接不上的时候,先检查是否是sql连接缺少时区问题,当连接少了?serverTimezone=UTC 会各种错误。
    比如遇见到的
    Creating a new SqlSession
    SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c4542cb] was not registered for synchronization because synchronization is not active
  2. Mapper method has an unsupported return type: class com.lee.entity.Employee
    如果sql语句执行成功,那么只是返回类型出了问题。
    出现这样的问题是因为 类型不匹配。
    在这里插入图片描述
    解决方法:

insert、delete、update操作默认返回一个int类型的整数,将增删改的接口改成int或者void即可。

select操作返回的类型可以是自定义的Map或者是List(目前遇到的),这里等我总结了resultType相关知识再回来补充!

如果有帮助点个赞,一起学习吧!

猜你喜欢

转载自blog.csdn.net/weixin_42797012/article/details/106955704