springboot java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)

报异常:

java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)

是database的配置写错了

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/test
    data-username: root
    data-password: 123456
spring.datasource.data-username= # Username of the database to execute DML scripts (if different).
看注释这个是用来单独执行DML脚本的如果设置了的话
正确的应该使用spring.datasource.username= # Login username of the database.	

完整的正确配置:

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/test
    username: root
    password: 123456

你可能感兴趣的:(Java学习笔记)