开发环境:idea+mysql8.0.21
问题描述:采用applicationContext.xml配置文件链接MySQL数据库时,当url配置如下:
<property name="url" value="jdbc:mysql://localhost:3306/eshop"/>
出现问题:
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”,即:
<property name="url" value="jdbc:mysql://localhost:3306/eshop?serverTimezone=GMT"/>