SpringBoot使用MySQL出现问题java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized o

错误

java.sql.SQLException: 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 utilize time zone support.

SpringBoot使用MySQL出现问题java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized o

解决方法

这个问题是因为我们使用SpringInitizar创建项目时选择的MySQL驱动程序的版本(默认是高版本)过高;在pom文件里点击选中并点击mysql-connector-java,跳转以后可以看到驱动程序的版本;
SpringBoot使用MySQL出现问题java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized o

1、在pom文件中指定MySql驱动程序的版本;
2、在url后面加上这个&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC;