SpringBoot学习笔记之mybatis集成

1)、pom.xml 配置maven依赖
org.mybatis.spring.boot
mybatis-spring-boot-starter
1.0.0

2)、一定要在启动的地方加上@MapperScan("com.vk.liyj.dao")

3)、配置文件中加上配置
#mybatis配置
mybatis.typeAliasesPackage=com.vk.liyj
#匹配mapper下的所有mapper.xml
#mybatis.mapperLocations=classpath:com/vk/liyj/mapper/*Mapper.xml
#匹配指定包下的所有mapper.xml
mybatis.mapperLocations=classpath*:com/vk/liyj/**/*Mapper.xml

测试方法:
执行com.vk.liyj.SpringBootJUnitTest.testMyBatis()

mybatis配置
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5
spring.datasource.validation-query=SELECT 1
spring.datasource.test-on-borrow=false
spring.datasource.test-while-idle=true
spring.datasource.time-between-eviction-runs-millis=18800
spring.datasource.jdbc-interceptors=ConnectionState;SlowQueryReport(threshold=0)

源码下载地址:http://download.csdn.net/download/liyuejin/9986140


你可能感兴趣的:(Spring,boot)