时区

【报错信息】:

1
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.

【解决方法】修改database的url:

1
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8

【报错信息】

1
java.sql.SQLException: Zero date value prohibited

​ Mysql数据库在面对0000-00-00 00:00:00日期的处理时,如果没有设置对应的对策,就会产生异常

【解决方法】在jdbcUrl中设置处理zeroDateTimeBehavior

1
driver-url=jdbc:mysql://127.0.0.1/test?zeroDateTimeBehavior=CONVERT_TO_NULL

ZERO日期会转化为null

注意:CONVERT_TO_NULL 一定是大写的,否则报错