异常 -- Spring Boot_Access denied for user ''@'192.168.137.1' (using password: NO)

昨天回家继续写SpringBoot的样例Demo,搞数据库的时候,死活连接不上去,抛出如下异常:

java.sql.SQLException: Access denied for user ''@'192.168.137.1' (using password: NO)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:871)
	at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4427)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1276)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2190)
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016)
异常 -- Spring Boot_Access denied for user ''@'192.168.137.1' (using password: NO)_第1张图片

后来,仔细对比了一下,之前写的Demo代码,发现配置文件中,写错了....

异常 -- Spring Boot_Access denied for user ''@'192.168.137.1' (using password: NO)_第2张图片

将:

spring.datasource.data-username=root
spring.datasource.data-password=root

换成:

spring.datasource.username=root
spring.datasource.password=root

替换之后,就可以了...

你可能感兴趣的:(代码异常/抛出异常)