今天写一段比较简单的调试代码,就一直保这个错误。
严重: create connection SQLException, url: jdbc:mysql://127.0.0.1:3306/myBatisTest, errorCode 0, state 08S01
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
网上的大部分问题都是修改连接超时的参数,但是修改后发现没有用。在查找整体代码的时候发现
配置文件中这个依赖的版本好像不是很对。
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
所以对这个依赖的版本进行了修改,降低到了5.1.47
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.47</version> </dependency>
再次运行的时候就通过了。