springboot数据库连接异常:java.sql.SQLException问题的解决

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配置文件中usernamepassword前面不能加 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

总结

具体缘由以后再说,任务要紧

原文地址:https://www.cnblogs.com/apebro/p/12571058.html