天天看點

java儲存json類型資料到mysql資料庫,mysql儲存json類型資料

1.首先在對應表添加一個

json

類型字段

java儲存json類型資料到mysql資料庫,mysql儲存json類型資料

2.在java對應的實體類添加對應的字段,重點是加上

(typeHandler = JacksonTypeHandler.class)

這個注解

java儲存json類型資料到mysql資料庫,mysql儲存json類型資料

不然的話儲存會報如下錯

Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'urlParams'. It was either not specified and/or could not be found for the javaType (com.alibaba.fastjson.JSONObject) : jdbcType (null) combination.

java儲存json類型資料到mysql資料庫,mysql儲存json類型資料

3.

mybatisPlus

查詢

json

類型資料結果為

null

,這個得在

@TableName

加上

autoResultMap = true

注解

java儲存json類型資料到mysql資料庫,mysql儲存json類型資料