springboot整合mybatis遇到的错误CannotGetJdbcConnectionException

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配置文件,大家根据自己的连接方式修改)
在这里插入图片描述
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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值