gradle依赖
implementation group: 'org.mapstruct',name:'mapstruct-jdk8',version:'1.3.1.Final' annotationProcessor "org.mapstruct:mapstruct-processor:1.3.1.Final"
mapper(前提是原始对象与目标对象属性一致,不一致的需要单独处理)
@Mapper public interface AbcMapper { AbcMapper INSTANCE = Mappers.getMapper(AbcMapper.class); List<Abc> bcdToAbc(List<Bcd> bcdList); }
使用
List<Abc> abcList = AbcMapper.INSTANCE.bcdToAbc(bcdList);
- 解决编译告警
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface AbcMapper { AbcMapper INSTANCE = Mappers.getMapper(AbcMapper.class); List<Abc> bcdToAbc(List<Bcd> bcdList); }
标签:Java,INSTANCE,MapStruct,List,AbcMapper,mapstruct,bcdToAbc,bcdList,拷贝 From: https://www.cnblogs.com/coderdxj/p/18098663