java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is un

使用数据库报错:
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.

超过6.0的版本配置文件:

  1. datasource.driver-class不是com.mysql.jdbc.Driver而是com.mysql.cj.jdbc.Driver.
  2. 在连接数据库的url后面,要添加一个serverTimezone
<dataSource type="POOLED">
	<property name="driver" value="com.mysql.cj.jdbc.Driver">property>
	<property name="url"
		value="jdbc:mysql://localhost:3306/mybatis?
	useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai">property>
	<property name="username" value="root">property>
	<property name="password" value="12345">property>
dataSource>

你可能感兴趣的:(异常)