除了常用的方法,可以试一下刷新Maven(自己刷新一下就好了,就是这么无语= 。=
导入MySQL依赖方式
<!-- mysql连接驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
配置MySQL文件方式
1.(成功的)
spring:
datasource:
url: jdbc:mysql://localhost:3306/mall?serverTimezone=UTC&characterEncoding=utf-8
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
2.(未成功)
spring:
application:
name: goods
datasource: #连接数据库配置
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/heima-estate?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
username: root
password: root
[补充]
突然想起来自己还手动导入了一个jar包