• java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more tha


    在使用SpringBoot +Mybatis 开发项目的时候,application.properties 中配置 Mysql 数据的模板如下:

    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mybatis_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
    spring.datasource.username=root
    spring.datasource.password=123456

    如果报下面的这个错误,

    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.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:569)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:512)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:480)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:498)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:494)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:69)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1634)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:637)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:351)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:224)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1358)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1414)
    at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1654)
    Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: 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.url=jdbc:mysql://localhost:3306/mybatis_test?characterEncoding=UTF-8 

    修改为: 

    spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mybatis_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai

  • 相关阅读:
    Week7 作业 A
    Mouth 1 模拟题 CSP201512-3 画图
    C++出现:error: passing 'const Employee' as 'this' argument of 'int Employee::getSalary()' discards qualifiers [-fpermissive]
    C++出现error: no match for call to '(MyCompare) (const key_type&, const Person&)'
    CentOS 7出现ifconfig:command not found
    有效清理C盘内存
    重装系统之后出现https:/ / logincdn.msauth.net/shared/1.0/content/js/ConvergedLogin_PCore_xxvbETmiVPe1AsI9xwHp3A2.js
    C++/QT运行时出现void value not ignored as it ought to be
    运行QT项目文件夹下的exe文件提示找不到“各种dll”
    Ubuntu16.04配置OpenCV3.2.0
  • 原文地址:https://www.cnblogs.com/wanglichaoya/p/13161170.html
Copyright © 2020-2023  润新知