springboot整合mybatis遇到的错误CannotGetJdbcConnectionException

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:\work\ideawork\springtest\target\classes\mapping\BookMapper.xml] ### The error may involve com.zxerjones.dao.BookDAO.getAll ### 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.

错误定位,mysql连接出错,网上找了好久终于找到解决方法(我使用的是yml配置文件,大家根据自己的连接方式修改)

aaaa

url后加上&serverTimezone=UTC&useSSL=false(SSL可加可不加,会有警告但是不影响,强迫症患者可以加上)

完整的url为:

url: jdbc:mysql://localhost:3306/library?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false

莫名奇妙的错误,上网查了一下,serverTimezone是设置时区的参数,但为什么会出错呢。经过查阅资料,mysql6.0以上必须配置此参数,这样问题就明朗了,UTC为全球标准时间,那我们也可以改为北京时间,把参数的值改为GMT%2B8就OK了;至于后后边的SSL参数,是关于网络通信中的一种确保安全和数据完整性的协议,与https关系密切,有兴趣的可以自己查一下。

参考:https://blog.csdn.net/yaphets__yj/article/details/77774874

 

 

你可能感兴趣的:(springboot错误整理)