springboot版本升级导致数据库连接报错:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized

    如题所示,当我们使用springboot版本高于2.1.4.RELEASE时,数据库驱动,默认变成了com.mysql.cj.jdbc.Driver,而非原来的com.mysql.jdbc.Driver,这个也直接导致了后面连接数据库会发生报错信息:

    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.

     解决办法就是给数据库连接url设置一个serverTimezone的参数,值可以是GMT-8,也可以是Asia/Shanghai,因为GMT-8需要转义一下连字符"-",所以配置属性为serverTimezone=GMT%2B8,如果是Asia/Shanghai就无须做转换了。

     

     

发布了529 篇原创文章 · 获赞 287 · 访问量 147万+

猜你喜欢

转载自blog.csdn.net/feinifi/article/details/103836362
今日推荐