今天连接数据库发现错误
找了好多资料才发现坑
我的数据库配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
data-username: root
data-password: 123456
username与password的前面都加了 data-,这是根据自动补全写的,这样写会就报错:Access denied for user ''@'localhost' (using password: NO)
正确配置如下、
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
username: root
password: 123456
完美解决