异常信息:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 510 milliseconds ago. The last packet sent successfully to the server was 504 milliseconds ago.
### The error may exist in com/lidongyang/dao/UserMapper.xml
### The error may involve com.lidongyang.dao.UserDao.getUserList
### The error occurred while executing a query
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
这个情况问题,我找了很久,通过后面两句的意思应该是链接数据库查询的时候出了错。
这样就应该是配置文件有问题
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</dataSource>
</environment>
</environments>
<!-- 每一个Mapper.xml都需要Mybatis核心配置文件中注册-->
<mappers>
<mapper resource="com/lidongyang/dao/UserMapper.xml"/>
</mappers>
</configuration>
通过测试是安全访问方式的错误。这里将useSSL的值改为false就可以了。
不知道原理,有大佬知道原理留个言。