数据库
首页 > 数据库> > 【Spring-BUG记录】数据库连接

【Spring-BUG记录】数据库连接

作者:互联网

项目场景:

创建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

原因分析:


解决方案:

标签:Spring,数据库,ssl,mysql,path,security,sun,BUG,Caused
来源: https://blog.csdn.net/m0_52410356/article/details/122140952