用useSSL=true或useSSL=false无法解决WARN: Establishing SSL connection without server’s identity verification is not recommended. …报错的解决方法(自用)
问题描述:
在b站自学mybatis,明明和视频操作一样但是报了WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.的错,百度了半个多小时解决方法基本都是在url加上useSSL=true或useSSL=false,但是我的就是没有用,后面就抱着试试看的心态重新建了一个项目,所有的内容都粘贴复制了一遍,因为之前上课跟着专业老师学的时候也连接了数据库,没有加useSSL也没有报错,但是选择的MySQL版本不一样,想着可能是这里的问题,就把它改了
这次运行终于没有报那个错了!!!!但是又报了另外一个错,Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
然后查到的解决方法是引入的mysql-connector-java依赖版本和mysql版本要一致(查自此文章 )
之前依赖版本
修改后依赖版本
修改完后记得修改配置文件中的driver
修改为com.mysql.cj.jdbc.Driver
再次运行,成功!
后面又想了想,之前那个项目报错解决不了会不会也是因为版本不一致的原因,于是又返回旧项目中将依赖版本修改了一下,也同样运行成功了