美文网首页
SpringBoot整合MyBatis以及MyBatisPlus

SpringBoot整合MyBatis以及MyBatisPlus

作者: SmileFH | 来源:发表于2021-05-03 15:16 被阅读0次
  1. 首先是mybatis-spring-boot-starter,和mybatis-plus-boot-starter,和mybatis-plus,有啥区别啊。原因我在项目中引入mybatis-plus3不能完成从MyBatisPlus到MyBatis的切换,但是换成mybatis-plus-boot-starter就可以了

在SpringBoot项目中引入MP的话,mybatis-plus-boot-starter包就好,这是官方整合好的。
如果使用MyBatis-Plus包的话,mybatis底层的mapper没有实现,无法直接使用,所以需要抽空看一下mybatis的底层实现。大概看了一眼,用代理实现的。
Mybatis-Plus BaseMapper自动生成SQL及MapperProxy

  1. org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.fh.bookstore.dao.UserMapper.selectById问题,明明在IService接口中就有这个方法,在BaseMapper中也有SelectByid方法,但是就是跑不通,报这个错。
    答:这个问题是因为在boot项目中引入mybatisplus依赖的情况下,没有实现底层的basemapper接口中的方法,所以不能用,至于为什么没有实现,还没有研究出来。

相关文章

网友评论

      本文标题:SpringBoot整合MyBatis以及MyBatisPlus

      本文链接:https://www.haomeiwen.com/subject/jrdpzktx.html