在连接数据库过程中出现下列错误
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.
一番查询后了解到这是因为jdbc-mysql6.0以上的版本在构建url时必须配置serverTimezone参数,例如:
jdbc:mysql://localhost:3306/ssm?serverTimezone=UTC
UTC:世界统一时间,跟北京时间相比,比北京时间要早8个小时,也就是说,你存入数据库的时间会比你自己输入的时间早八个小时,所以要serverTimezone时间设为北京时间,即:
serverTimezone=GMT%2B8
或者上海时间
serverTimezone=Asia/Shanghai