起初这样能短暂解决问题,后来发现每次机器重启了就还是有这样的错误,还是要执行SQL,很麻烦:

show variables like '%time_zone%';

select now();

set global time_zone = '+8:00';

flush privileges;

其实这个不是spring boot + mybatis的问题, 其实是为了使MySQL JDBC驱动程序的5.1.33版本与UTC时区配合使用,必须在连接字符串中明确指定serverTimezone。

jdbc:mysql://localhost:3306/testdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

 

相关文章:

  • 2021-03-31
  • 2021-05-27
  • 2021-04-29
  • 2021-09-16
  • 2021-04-04
  • 2021-04-05
  • 2021-11-26
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
相关资源
相似解决方案