DozerMapper:对象转换器使用教程-创新互联
dozer GitHub地址:https://github.com/DozerMapper/dozer
官方wiki:Introduction · GitBook
第一步:导包com.github.dozermapper dozer-core 6.5.2
第二步:配置转换器
DozerConfig.java文件package com.ymf.invoice.config;
import com.github.dozermapper.core.DozerBeanMapperBuilder;
import com.github.dozermapper.core.Mapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
import java.util.List;
@Configuration
public class DozerConfig {@Bean
public Mapper dozerBeanMapper() {ListmappingFiles = Arrays.asList(
"dozer-configration-mapping.xml"
);
return DozerBeanMapperBuilder.create()
.withMappingFiles(mappingFiles)
.build();
}
}
dozer-configration-mapping.xml文件
第三步:简单测试import com.github.dozermapper.core.Mapper;
@Autowired
private Mapper mapper;
InvoiceTaskDto invoiceTaskDto = mapper.map(invoiceTask, InvoiceTaskDto.class);
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
网站题目:DozerMapper:对象转换器使用教程-创新互联
网页网址:http://tyjierui.cn/article/shgec.html