报错内容:
Cause: 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.
报错内容解释:
原因:java.sql.SQLException:无法识别服务器时区值’�й���ʱ��’或表示多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。
报错原因:
MySQL jdbc 6.0 版本以上必须配置“serverTimezone”参数。
解决方案:
数据库 url 值要配置“serverTimezone=UTC”
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC"/>
注:UTC 代表的是全球标准时间,若我们使用的时间是北京时区也就是东八区,领先 UTC 八个小时。url 的时区使用中国标准时间。也是就serverTimezone=Asia/Shanghai。