天天看点

spring boot全家桶 ---- 第三章 笔记二

一、通过 MyBatis 操作数据库

在 Spring 中使⽤用  MyBatis

1、MyBatis Spring Adapter(https://github.com/mybatis/spring)

2、MyBatis Spring-Boot-Starter(https://github.com/mybatis/spring-boot-starter)

二、简单配置

mybatis.mapper-locations = classpath*:mapper*.xml 

mybatis.type-aliases-package = 类型别名的包名

mybatis.type-handlers-package = TypeHandler扫描包名

mybatis.configuration.map-underscore-to-camel-case = true   下划线对应拓分

三、Mapper 

@MapperScan   定义扫描路径

@Mapper 定义接口

映射的定义

四、工具  :MyBatis Generator 官方代码生成器

1、配置

generatorConfiguration

 context

jdbcConnection  

javaModelGenerator 

sqlMapGenerator 

javaClientGenerator (ANNOTATEDMAPPER / XMLMAPPER / MIXEDMAPPER)

 table 

继续阅读