错误:The driver has not received any packets from the server.
大概率是MySQL版本与mysql-connector-java版本对应不上。 一开始百度搜的其他方法都试过了还是没用,后来发现自己MySQL版本是5.7,而pom.xml中的mysql-connector-java的版本为8.0的。 将pom.xml中的mysql-connector-java改为:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
再将数据源的yml文件的driver-class-name去掉cj:
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
改为
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.jdbc.Driver
|