0
点赞
收藏
分享

微信扫一扫

在Spring boot中整个mybatis时出错

高子歌 2022-04-20 阅读 68

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:129) ~[mysql-connector-java-8.0.17.jar:8.0.17]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.17.jar:8.0.17]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.17.jar:8.0.17]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.17.jar:8.0.17]

原因是URL的时区配置的不对

我在URL后添加&serverTimezone=Asia/Shanghai就可以了

完整的URL是

url: jdbc:mysql://127.0.0.1:3306/database?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai

或者

url: jdbc:mysql://127.0.0.1:3306/database?useSSL=false&requireSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai

 

举报

相关推荐

0 条评论