Mybatis出坑记

Springboot mybatis集成 Invalid bound statement (not found)

https://blog.csdn.net/qq_35981283/article/details/78590090

后来实在没办法了,跟以前的项目逐一比对,发现application.properties中忘记了mybatise的两行配置:

mybatis.typeAliasesPackage=com.test.shiro.entity
mybatis.mapperLocations=classpath:mapper/*.xml
主要是mybatis.mapperLocations=classpath:mapper/*.xml,加上之后OK了

Mybatis Mapper vs DAO

https://www.cnblogs.com/alsf/p/9295917.html

https://blog.csdn.net/qq_22172133/article/details/81275833

分析上面的代码会发现有大量的重复的模板代码,并且存在硬编码【如sqlSession.insert("test.insertUser", user);】,为了解决以上问题,故采用开发mapper接口(相当于dao接口)来进行dao的开发,即通过开发mapper接口,将自动生成其代理类来进行操作。其中Mapper代理使用的是jdk的代理策略。如果采用Mapper代理的方式开发需要满足如下开发规范:

    mapper接口的全限定名要和mapper映射文件的namespace值一致。
    mapper接口的方法名称要和mapper映射文件的statement的id一致。
    mapper接口的方法参数类型要和mapper映射文件的statement的parameterType的值一致,而且它的参数是一个。
    mapper接口的方法返回值类型要和mapper映射文件的statement的resultType的值一致。

Mybatis Generator

官方文档 http://mybatis.org/generator/index.html

生产力工具 https://www.jianshu.com/p/bcef87ea77e6

mybatis-generator使用备忘 https://cloud.tencent.com/developer/article/1120370

https://github.com/dcendents/mybatis-generator-plugins/blob/master/README.md

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值