修机械师怎么做我小样网站角仰望,阿里云 企业 网站,wordpress生成标签页,搜索引擎seo是什么意思一、传输对象的方式
将对象从内存传输到磁盘进行保存#xff0c;或者进行网络传输#xff0c;有两种方式#xff1a;
实现Serializable接口#xff0c;直接传输对象转成json字符串后#xff0c;进行字符串传输
二、直接传输对象
implements Serializable
Data
Equal…一、传输对象的方式
将对象从内存传输到磁盘进行保存或者进行网络传输有两种方式
实现Serializable接口直接传输对象转成json字符串后进行字符串传输
二、直接传输对象
implements Serializable
Data
EqualsAndHashCode(callSuper false)
Accessors(chain true)
TableName(learning_lesson)
ApiModel(valueLearningLesson对象, description学生课程表)
public class LearningLesson implements Serializable {private static final long serialVersionUID 1L;ApiModelProperty(value 主键)TableId(value id, type IdType.ASSIGN_ID)private Long id;ApiModelProperty(value 学员id)private Long userId;ApiModelProperty(value 课程id)private Long courseId;ApiModelProperty(value 课程状态0-未学习1-学习中2-已学完3-已失效)private LessonStatus status;ApiModelProperty(value 每周学习频率例如每周学习6小节则频率为6)private Integer weekFreq;ApiModelProperty(value 学习计划状态0-没有计划1-计划进行中)private PlanStatus planStatus;ApiModelProperty(value 已学习小节数量)private Integer learnedSections;ApiModelProperty(value 最近一次学习的小节id)private Long latestSectionId;ApiModelProperty(value 最近一次学习的时间)private LocalDateTime latestLearnTime;ApiModelProperty(value 创建时间)private LocalDateTime createTime;ApiModelProperty(value 过期时间)private LocalDateTime expireTime;ApiModelProperty(value 更新时间)private LocalDateTime updateTime;
}举例Redis直接传输对象 单元测试 //使用RedisTemplateString,Object需要配置一个RedisTemplateString,ObjectAutowiredprivate RedisTemplateString,Object redisTemplate;Testpublic void Test1_Add(){User u User.builder().id(1000).name(zhangsan).phone(15730000001).build();redisTemplate.opsForValue().set(user1, u);}Testpublic void Test1_Get(){Object obj redisTemplate.opsForValue().get(user1);// 这里不能把Object强转为User类 否则会java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.gzdemo.redisdemo.domain.UserUser user JSONUtil.toBean(JSONUtil.toJsonStr(obj), User.class);System.out.println(user);}如果不implements Serializable会报错除非RedisTemplateString,Object配置了各种序列化器。