SSM整合报错:The server time zone value xxx is unrecognized or represents more than one time zone.

报错信息:

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.

**出错的原因:**各类博客将问题归于mysql与mysql-connector-java版本不兼容。我使用的是mysql8.0.18,mysql-connector-java也是8.0.18。

解决方法:
除了将版本降级,还可以通过以下方法修正该错误(大小写需一致):
在jdbcUrl的value后面,加上?serverTimezone=UTC
例如:

<property name="jdbcUrl" value="jdbc:mysql:///ssm?serverTimezone=UTC"/>

也有解决方案是,加上?serverTimezone=UTC&characterEncoding=utf-8,即

<property name="jdbcUrl" value="jdbc:mysql:///ssm?serverTimezone=UTC&characterEncoding=utf-8"/>

成功修正bug
SSM整合报错:The server time zone value xxx is unrecognized or represents more than one time zone._第1张图片

你可能感兴趣的:(java踩坑)