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

今天系统报2个错如下

1.Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

2.Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

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

第一个我百度了以后,说是程序里实体的字段类型和数据库不匹配,我检查以后发现是匹配的没有问题。然后我就看报的第二个错,sqlException,Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

公司大佬告诉我在配置文件

spring.datasource.url的后面加上“&zeroDateTimeBehavior=convertToNull”就好了。我打开配置文件一看,果然配置文件spring.datasource.url中没有这么一句话。于是我半信半疑的把“&zeroDateTimeBehavior=convertToNull”加上了,果然好了!

原来是这样的:

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

在useSSL=false后面加上“&zeroDateTimeBehavior=convertToNull”就可以了,如下:

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