解决方法:
1.
@DateTimeFormat(pattern = “yyyy-MM-dd”)
@JsonFormat(pattern=“yyyy-MM-dd”,timezone=“GMT+8”)
private Date date;//这里是你自己的时间字段,上面加两个注解
在连接数据库的语句后面添加参数:serverTimezone=GMT%2B8
characterEncoding=utf8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8
加完之后发现还是差一天(其实还是差八小时),发现原来是前端传过来的就是差八小时的,不是后台的问题了,前台也需要对时间的时区进行配置!!! 坑啊,找了老半天!
`