一、引入mysql8依赖
<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.23</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.21</version></dependency>
二、yaml配置
spring:datasource:username: rootpassword: 123456driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/spring_security?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8type: com.alibaba.druid.pool.DruidDataSource
注意:报错检查自己的数据库账号和密码是否正确,和数据库主机端口等