场景:

Spring Boot配置MySQL数据源时报错:java.sql.SQLException: 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.

原因:配置项错误

原配置

spring:
  datasource:
    username: root
    password: 983934
    url: jdbc:mysql://127.0.0.1:3306/spring-boot-learn
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource

正确的配置

spring:
  datasource:
    username: root
    password: 983934
    url: jdbc:mysql://127.0.0.1:3306/spring-boot-learn?serverTimezone=UTC
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource
最后修改日期:2020-07-12

作者

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。