Mapper测试类中运行时报错:
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
### The error may exist in com/itheima/mapper/StudentMapper.java (best guess)
### The error may involve com.itheima.mapper.StudentMapper.findAll
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
如图:
然后findAll下会出现红色下划线,如图:
在运行Service测试类中会一直运行,一直框中不断出error,如图:
可能的原因及其解决方法:
应用程序试图使用不兼容的认证协议连接到 MySQL 数据库,从 MySQL 5.7 开始,它使用了一个新的默认密码插件 caching_sha2_password
作为其认证机制,而较老的客户端可能不支持这个认证插件,在pom文件中升级 Mysql JDBC驱动
更改、应用过后,就好了: