版权声明:本文为博主原创文章,用来记录学习过程,欢迎交流学习。 https://blog.csdn.net/k_young1997/article/details/88717651
在用mybatis搭建项目时,报了如下错误
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is 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.
在前端显示如下
以上报错有一句话翻译过来是
如果要使用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。
这个报错是因为 mybatis的配置文件application.properties ,中的url少写了serverTimezone=UTC。
我原本的url如下:
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
修改过后的如下:
spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
修改之后运行正常