springboot+mybatis+mysql 出现的简单500错误问题

 页面报500的时区错误,详情如下:

2019-03-21 17:49:20.591 ERROR 5088 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### 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. ### The error may exist in file [D:\springboot-mybatis-demo\target\classes\mapping\UserInfoMapper.xml] ### The error may involve com.ocean.dao.UserInfoMapper.findAllUser ### The error occurred while executing a query ### 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.] with root cause

 

从描述可知道是个时区的错误,解决方法也很简单:

在配置文件中,将连接字符串后加上&serverTimezone=GMT或者UTC,即可解决上述问题

spring:
  datasource:
    name: test
    url: jdbc:mysql://127.0.0.1:3306/*****?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
   

?useUnicode=true&characterEncoding=utf-8可以解决前后端分离情况下,前端中文在mysql数据库中显示???的问题。

你可能感兴趣的:(springboot+mybatis+mysql 出现的简单500错误问题)