java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)問題的解決
問題描述
- 問題:
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
- 找到原因
Caused by: java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
- 問題查找
application.yml文件
#2、數據庫連接池
datasource:
drive-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3328/moms?userUnicode=true&characterEncoding=utf8
data-username: root
data-password: 123
問題解決
application.yml配置文件中username和password前面不能加 data-
#2、數據庫連接池
datasource:
drive-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3328/moms?userUnicode=true&characterEncoding=utf8
username: root
password: 123
總結
具體緣由以后再說,任務要緊