1.导入数据库需要的依赖(引入了依赖,一定要刷新maven)
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
2.
3.配置yml文件
spring:
datasource:
url: jdbc:mysql://localhost:3306/qcby_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=CTT
username: root
password: driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
mapper-locations: classpath:mapper/*.xml #对应mapper映射xml文件所在路径
type-aliases-package: com.xxxx.entity #对应实体类路径