学习spring-cloud时,访问目标页时报错如标题所示,发现可能是配置文件application.yml出现了错误
原因:
使用的高版本(6.x.x以上)Mysql数据库会与系统时区有差异造成异常。
解决方法:
配置文件修改如下
在jdbc连接的URL后面添加serverTimezone=GMT
由于中国处于东八区,因此需要写成serverTimezone=GMT%2B8,否则得到的时间会系统时间相差8个小时。
datasource:
url: jdbc:mysql://localhost:3306/mall?serverTimezone=GMT%2B8&useUnicode=true&useSSL=false&characterEncoding=utf8
driver-class-name: com.mysql.cj.jdbc.Driver
username: xxx
password: xxx
然后就没有报错了