天天看點

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 

繼續閱讀