Spring-BUG记录数据库连接
Posted ggzx666
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
原因分析:
解决方案:
- 数据库版本要和maven配置mysql-connector-java一致
- 这里需要把ssl设置为false
以上是关于Spring-BUG记录数据库连接的主要内容,如果未能解决你的问题,请参考以下文章
Spring-BUG添加语句<tx:annotation-driven transaction-manager=“txManager“/>报错
Spring-BUG添加语句<tx:annotation-driven transaction-manager=“txManager“/>报错