问题描述:
提示:这里描述项目中遇到的问题:
控制台中警告部分代码:
为方便查看已换行处理
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.
原因分析:
提示:先去看pom.xml里面的MySQL版本问题
一开始我觉得是pom.xml
里面MySQL版本不对
但是经过检查发现是8.0的版本,并不是上面说的MySQL 5.5.45+, 5.6.26+ and 5.7.6+ 版本
这时候看到了报错的最后一句话:
为方便查看报错已换行处理
You need either to explicitly disable SSL by setting useSSL=false,
or set useSSL=true and provide truststore for server certificate verification.
解决方案:
提示:这里填写该问题的具体解决方案:
在application.yml
文件内的url
那行最后加上:&useSSL=false
使这行变成(已换行处理):
url: jdbc:mysql://localhost:3306/数据库名字?useUnicode=true
&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true
&useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false
再次运行程序就没有警告了,其实警告WARN不用管,并不影响程序运行
扩展:
如果没有在application.yml
文件内的url
那行最后加上:&useSSL=false
也有可能会导致另一个关闭警告:
closing inbound before receiving peer‘s close_notify
项目在关闭的时候出现的问题,这其实是个警告,警告不用管
具体报错信息如下:
javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:837)
at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:816)
at com.mysql.cj.protocol.a.NativeProtocol.quit(NativeProtocol.java:1312)
at com.mysql.cj.NativeSession.quit(NativeSession.java:182)
at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1750)
at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:720)
at com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:135)
at com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:441)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
在application.properties
文件里面,在编写URL那行最后加上:&useSSL=false
再次运行项目后停止: