Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.Tue Apr 30 21:15:36 CST 2019There was an unexpected error (type=Internal Server Error, status=500).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 com/mkl/mapper/UserMapper.java (best guess) ### The error may involve com.mkl.mapper.UserMapper.selectByPrimaryKey ### 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.
这是今天在学习spring cloud的时候,连接数据库出现的bug,用的spring的手脚架创建的项目,看了下是MySQL默认的时区是UTC时区 的问题,临时解决方法是在连接地址后面跟?serverTimezone=GMT%2B8,也就是这样jdbc:mysql://localhost:3306/mybatis?serverTimezone=GMT%2B8,现在能正常获取数据了,永久解决的话:修改mysql的配置文件,添加:default-time-zone=’+08:00’,重启mysql生效