关于Mybatis-Plus查询Mysql8 json 格式的数据,返回为null问题和插入报错的问题

image

 数据库字段类型是json

image

 字段有值,但是查询你后返给前端是null

image

 插入报错需要添加对应的 typeHandler,可以是框架自带的,也可以是自定义的,自定义的需要注册(@TableField(typeHandler = ListTypeHandler.class))

Error updating database. Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'xxxxxx'. It was either not specified and/or could not be found for the javaType (java.util.List) : jdbcType (null) combination.\r\n### The error may exist in org/xxxx/modules/userdata/mapper/xxxxMapper.java (best guess)\r\n### The error may involve org.xxxx.modules.userdata.mapper.xxxxxMapper.insert\r\n### The error occurred while executing an update\r\n### Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'xxxxxx'. It was either not specified and/or could not be found for the javaType (java.util.List) : jdbcType (null) combination.

查询为null:需要把自动映射加上autoResultMap = true,默认是false

image

image

 改完配置后再查询

image

 

 

 





posted @ 2025-11-06 17:54  FlyingBread  阅读(49)  评论(0)    收藏  举报