您的位置:首页 > 编程语言 > Java开发

SpringBoot(十)-- 整合MyBatis

2017-11-05 11:33 639 查看
1.pom.xml 配置maven依赖

<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>


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

3.配置文件中加上配置

spring.datasource.url=jdbc:mysql://localhost:3306/consult
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=org.gjt.mm.mysql.Driver

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)

mybatis.typeAliasesPackage=com.xsjt.bean
mybatis.mapperLocations=classpath:com/xsjt/xml/*Mapper.xml


4.源码下载

  https://gitee.com/xbq8023/spring-boot-learn
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: