springboot启动报错com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

一般报这个错就是springboot数据库连接配置参数的问题;以下这几项参数一定要检查没问题;

后面的报错可能会出现下面这种报错;这种原因是mysql的ssl连接问题,5.6以上默认useSSL=true也就是需要证书的方式连接;

Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateNotYetValidException: NotBefore: Tue Jul 14 19:38:12 CST 2020
	at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_152]
	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959) ~[na:1.8.0_152]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) ~[na:1.8.0_152]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) ~[na:1.8.0_152]
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514) ~[na:1.8.0_152]
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) ~[na:1.8.0_152]
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026) ~[na:1.8.0_152]
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:961) ~[na:1.8.0_152]
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072) ~[na:1.8.0_152]
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) ~[na:1.8.0_152]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413) ~[na:1.8.0_152]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397) ~[na:1.8.0_152]
	at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:336) ~[mysql-connector-java-8.0.19.jar:8.0.19]
	at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188) ~[mysql-connector-java-8.0.19.jar:8.0.19]
	at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99) ~[mysql-connector-java-8.0.19.jar:8.0.19]
	at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:329) ~[mysql-connector-java-8.0.19.jar:8.0.19]
	... 67 common frames omitted

解决方案:

url后面拼接加上useSSL=false即可

你可能感兴趣的:(springboot,java后端,mysql,java)