Loading

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

总结

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

posted @ 2020-03-25 22:25  平头猿小哥  阅读(10476)  评论(0编辑  收藏  举报