创建spring项目在使用maven调用数据库连接依赖时报错
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 十二月 25, 2021 11:25:10 上午 com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl error 严重: create connection error com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
这里是maven配置的依赖有问题,使用的mysql-connector-java依赖版本应该和数据库版本一致
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> </dependency>
然后又报错了,不够这个是另一个错误
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
jdbc.url=jdbc:mysql://localhost:3306/goods?serverTimezone=Asia/Shanghai&useSSL=true
这里需要把ssl设置为false