原因是我之前用的是,version 5.0.14 版本,后来升级了mysql的版本,升成了8.0版本,然后之前的驱动mysql-connector-java 5.0版本不可以适配,然后下载了8.0.17 版本驱动,
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.17</version> </dependency>
后来又报了,这个错
The server time zone value '�й���ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to...
查了资料说Mysql Connector/J 6.x以上的版本,会报时区的错误,跟这个错描述的是一样的,然后加上时区的配置,如下:
在配置url的时候不能简单写成 :
jdbc:mysql://localhost:3306/data?characterEncoding=UTF-8
而是要写成 :
jdbc:mysql://localhost:3306/data?characterEncoding=UTF-8&serverTimezone=UTC
然后重新启动就不报错了