Java生成日期时间存入Mysql数据库的实现方法
350
2022-07-27
目录待转换的类目标类转换接口测试类
前言:
MapStruct支持Spring的依赖注入机制,只须要在@Mapper注解中添加componentModel配置项,并设置为“spring”便可。
待转换的类
@Getter
@Setter
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Spu {
private Integer id;
private String name;
private String caption;
private String pics;
private String specs;
private String unit;
private Integer hot;
private Integer comments;
private Integer agrees;
private Integer recommend;
private Integer status;
private String service;
private String sVajfDcAQinfo;
private Integer countryId;
private String addr;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}
目标类
@Getter
@Setter
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SpuVO {
private Integer id;
private String name;
private String caption;
private String pics;
private String specs;
private String unit;
private String service;
private String addr;
}
转换接口
@Mapper(componentModel = "spring")
public interface SpuTrans {
List
}
测试类
@Controller
@RequestMapping()
public class IndexController {
@Resource
private SpuTrans spuTrans;
@Resource
private SpuService spuService;
@GetMapping("/list")
public ModelAndView list(ModelAndView mav) {
//轮播图
List
List
mav.addObject("spuVOList", spuVOList);
mav.setViewName("spu_list");
rhttp://eturn mav;
}
}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~