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.
在application.properties中在数据库url后添加serverTimezone=Asia/Shanghai
因为默认情况下serverTimezone=UTC,比我们北京时间早8小时,写入数据库更新时间和系统时间不一致可能会报错
spring.datasource.url=jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai

本文详细解释了如何解决在使用MySQL数据库时遇到的时区设置问题,特别是在将数据写入数据库时,由于服务器时区与本地时区不一致导致的时间显示错误。通过在application.properties文件中的数据库URL后添加serverTimezone参数,可以配置数据库使用特定的时区,如Asia/Shanghai,从而确保数据库中的时间与本地系统时间一致。
789

被折叠的 条评论
为什么被折叠?



