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

 

你可能感兴趣的:(工具效能,中台建设实践心得,后端)