启动项目错误信息
Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure
Caused by: java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) at sun.security.ssl.HandshakeContext.(HandshakeContext.java:171) at sun.security.ssl.ClientHandshakeContext.(ClientHandshakeContext.java:101) at sun.security.ssl.TransportContext.kickstart(TransportContext.java:238) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:373) at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:336) at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188) at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99) at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:325) … 54 common frames omitted
场景
本地启动springboot项目,结果报错上述错误,但是其他同事本地启动没问题,linux服务器上也没问题,后来发现是本地安装的jdk版本问题,版本如下:
- 我的JDK(启动报错): 1.8.0_291;
- 同事的JDK(启动正常): 1.8.0_201;
问题分析
旧版本的JDK默认不使用SSL连接mysql 新版本的JDK默认使用SSL连接mysql
解决办法
连接地址增加useSSL=false,如 jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true**&useSSL=false**
|