报错java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

报错环境是maraiadb5.5所用的时间字段是timestamp,mariadb5.6用的datetime的mariadb是不会报这个错误的
在这里插入图片描述
原配置为:
spring.datasource.url=jdbc:mysql://10.44.100.217:3306/xxx_test?autoReconnect=true&useSSL=false&allowMultiQueries=true
修改后配置为:
spring.datasource.url=jdbc:mysql://10.44.100.217:3306/xxx_test?autoReconnect=true&useSSL=false&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull
这类异常的发生和所用字段类型timestamp有关系,后加zeroDateTimeBehavior=convertToNull是将为0的时间类型以null的方式传输

猜你喜欢

转载自blog.csdn.net/qq_38224158/article/details/84032356