1.数据库健康检查,isValid()
org.springframework.dao.InvalidDataAccessApiUsageException: ConnectionCallback; isValid; nested exception is java.sql.SQLFeatureNotSupportedException: isValid
解决方案1.:
management:
health:
db:
enabled: false #关闭数据库健康检查isValid
解决方案2:创建一个配置文件DataSourceHealthConfig.java
2.记录一次datetime转LocalDateTime报错,getObject with type
org.springframework.dao.InvalidDataAccessApiUsageException: Error attempting to get column 'create_time' from result set. Cause: java.sql.SQLFeatureNotSupportedException: getObject with type
; getObject with type; nested exception is java.sql.SQLFeatureNotSupportedException: getObject with type
解决方案:
具体可参考下面地址详细解说!
Cause: java.sql.SQLFeatureNotSupportedException: getObject with type-CSDN博客
配置文件中添加mybatis-typehandlers-jsr310组件包
<!--mybatis-typehandlers-jsr310必须在mybatis-plus-boot-starter前面-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
3.Can not update sharding key
原因分析:
1.在使用sharding-jdbc分表中,本人采用了create_time作为分表字段,
2.Preparing:UPDATE sharding_order SET name=?, create_time=?, updater=? WHERE id=?
Parameters: 商品-update(String), 2022-07-10 15:59:53.0(Timestamp), null, 1040294735639478272(Long)
3.可以发现,其中create_time被更新了,而sharding-jdbc只允许更新create_time字段的值必须和原有值一样,才不会报错,数据库存储的时 2022-07-10 15:59:53,最新时2022-07-10 15:59:53.0(变化了)(数据库设计字段位datetime类型,java为LocalDateTime )(不太明白为什么多了一个.0,大佬看到帮忙解释下)
4.解决方案:
1.新建一个字段存储格式位YMD的
2.添加注解,updateStrategy = FieldStrategy.NEVER,永久不更新这个字段
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
private LocalDateTime createTime;