springboot连接mysql8.0问题解决

原配置如下:

spring.datasource.url=jdbc:mysql://47.112.103.249:3306/management?useSSL=true&allowMultiQueries=true

    mysql
    mysql-connector-java
    8.0.11

报错信息包含如下:

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.


Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any off the trust anchors

解决:

将spring.datasource.url中的useSSL=true 改为false,如果去掉useSSL会有如下警告

Mon Feb 10 01:03:13 CST 2020 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.
 

你可能感兴趣的:(springboot,mysql8.0)