问题背景:
在使用idea和mybatis进行查询时,出现此错误,mapper已经注册,maven的配置文件过滤也已经去除,数据库测试连接成功
问题分析:
排除以上错误和自己粗心的错误,通过百度和各种博客,尝试了以下操作
1、在配置文件的mysqld标签下添加如下:
wait_timeout=28800
interactive_timeout=28800
2、通过命令行设置这两个属性然后重启服务
均没有解决问题
解决方法:
最后发现在mybatis核心配置文件中,url的地方,设置了这样一个属性,useSSL=true,将true改为false即可,在网上找到了一点关于这个问题的解释:
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
不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果不设置显式选项,则必须建立默认的SSL连接。您需要通过设置useSSL=false显式地禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储
MySQL在高版本需要指明是否进行SSL连接
SSL协议提供服务主要:
1)认证用户服务器,确保数据发送到正确的服务器; .
2)加密数据,防止数据传输途中被窃取使用;
3)维护数据完整性,验证数据在传输过程中是否丢失;