mysql字段内容是json 通过mybtis直接转换成对象输出方法

1.映射对象中需要加注解

@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "user", autoResultMap = true)
public class user implements Serializable {

    
    private String name;
   
    private String age;

	@TableField(typeHandler = JacksonTypeHandler.class)
    private demoJson demoJson;

}

2.mybatis里加入

   <result property="demoJson" column="demo_json" jdbcType="VARCHAR" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>

你可能感兴趣的:(学习类,mysql,json,mybatis)