- 批量转换
# 编写convert
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public abstract class CarConvert {
public static CarConvert INSTANCE = Mappers.getMapper(CarConvert.class);
public abstract List<CarVO> dtos2vos(List<CarDTO> carDTO);
}
# 测试
/**
* 测试mapstruct批量转换
* List<CarDto>--> List<CarVo>
*/
@Test
public void test3() {
CarDTO carDTO = buildCarDTO();
List<CarDTO> carDTOList = new ArrayList<>();
carDTOList.add(carDTO); // source
// target
List<CarVO> carVOList = CarConvert.INSTANCE.dtos2vos(carDTOList);
System.out.println(carVOList);
}
标签:carDTOList,CarConvert,carDTO,MapStruct,List,使用,public
From: https://www.cnblogs.com/chniny/p/16750060.html