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.
上网查找解决方案,发现是我的配置文件application.yml中数据库url地址的问题。
#服务器配置
server:
port: 8181
#spring配置
spring:
#数组源
datasource:
url: jdbc:mysql://localhost:3306/bookmsg
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
#mybatis-plus配置
mybatis-plus:
type-aliases-package: cn.taoqx.bookdata.pojo
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
查询到的解决方案如下:(猜测估计是因为SpringBoot 2.1.x版本使用的的jdbc驱动是6.0版本以上吧)
原因是因为使用了Mysql Connector/J 6.x以上的版本,然后就报了时区的错误
遇到的问题: servertime=UTC导致时间差8个小时
MySQL jdbc 6.0 版本以上必须配置此参数
解决办法:
在配置url的时候不能简单写成 :jdbc:mysql://localhost:3306/mysql
而是要写成 :jdbc:mysql://localhost:3306/mysql?serverTimezone=UTC
#服务器配置
server:
port: 8181
#spring配置
spring:
#数组源
datasource:
url: jdbc:mysql://localhost:3306/bookmsg?serverTimezone=UTC
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
#mybatis-plus配置
mybatis-plus:
type-aliases-package: cn.taoqx.bookdata.pojo
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl