java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors(代码片

Posted 闲言_

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors(代码片相关的知识,希望对你有一定的参考价值。

错误产生环境

单独配置Mybatis 工程,测试时产生

错误描述

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 336 milliseconds ago.  The last packet sent successfully to the server was 332 milliseconds ago.
### The error may exist in cn/bloghut/dao/UserMapper.xml
### The error may involve cn.bloghut.dao.UserDao.getUser
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
java.security.cert.CertPathValidatorException: Path does not 
chain with any of the trust anchors

Caused by: java.security.cert.CertPathValidatorException: 
Path does not chain with any of the trust anchors


错误原因

在数据库连接时使用了 userSSL 参数,将sueSSL = true 改为 useSSL = false,项目可以正常跑起来了。

解决办法

修改前

 <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&amp;useUnicode=true&amp;characterEncoding=UTF8"/>

修改后

 <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF8"/>

以上是关于java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors(代码片的主要内容,如果未能解决你的问题,请参考以下文章