之前已经搭建了springboot项目,参考 使用Springboot快速搭建项目
现在添加使用mybatis
pom.xml添加依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.42</version>
</dependency>
application.yml中添加datasource配置
注意层级关系
server:
port: 8080
spring:
http:
encoding:
charset: utf-8
enabled: true
force: true
datasource:
driver-class-name: com.mysql.jdbc.Drive