首页 > 技术文章 > spring boot启动异常: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

ssjf 2019-09-02 15:20 原文

项目启动时提示: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.

yml配置

spring:
  profiles:
    active: dev

  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&characterEncoding=utf8
    username: eric
    password: 123456

  jpa:
    hibernate:
      ddl-auto: create
    show-sql: true
解决方案1
在mysql中执行命令: 
set global time_zone='+8:00' 
解决方案2
修改application.properties数据库配置,添加serverTimezone=UTC:
url:jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC

推荐阅读