导入依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
配置
application.properties
spring:
datasource:
username: root
password: 123456
url: jdbc:mysql://localhost:3306/myblog?useUnicode=true&characterEncoding=utf-8
driver-class-name: com.mysql.jdbc.Driver
mybatis:
type-aliases-package: com.blog.myblog.pojo
mapper-locations: classpath:mybatis/mapper/*.xml