1、导入mybatis的起步依赖mybatis-spring-boot-starter
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
2、在yml里编写数据库驱动
我的mysql5
spring:
datasource:
url: jdbc:mysql://localhost:3306/表名?useSSL=false
username: root
password: ele994
driver-class-name: com.mysql.jdbc.Drive
# driver-class-name: com.mysql.cj.jdbc.Driver
我的mysql8
spring:
datasource:
url: jdbc:mysql://localhost:3307/表名?useSSL=false
username: root
password: ele994111
driver-class-name: com.mysql.jdbc.Driver
# driver-class-name: com.mysql.cj.jdbc.Driver