SpringBoot 数据库连接失败

今天在测试springboot的时候遇到一个问题,数据库一直连接不上,服务器报错:

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.

上网查询了一下,原因是我的表里面有一个字段使用了datetime类型,使用 mybatis-generator
生成的enty文件里面自动转化为了Date类型,需要指定时区才可以使用,所以在jdbc的url地址后面添加serverTimezone=UTC。完整的地址如下:

spring.datasource.url=jdbc:mysql://192.168.2.199:3306/jump?characterEncoding=utf-8&&useUnicode=true&&zeroDateTimeBehavior=convertToNull&&serverTimezone=UTC
Search by:GoogleBingBaidu