【亲测好用】applicationContext.xml配置链接MySQL数据库,出现问题“The server time zone value ‘�й���׼ʱ��‘ ”解决方案

 

 

开发环境:idea+mysql8.0.21

问题描述:采用applicationContext.xml配置文件链接MySQL数据库时,当url配置如下:

出现问题:

Caused by: 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.

原因:数据库MySQL的驱动是8.0.18,与系统时区存在差异

解决方案:在url后面加上“serverTimezone=GMT”,即:

你可能感兴趣的:(java)