我正在更新一个bean 根据文档:
@Mapper
public interface CarMapper {
void updateCarFromDto(CarDto carDto, @MappingTarget Car car);
}
是否可以告诉mapstruct忽略某个字段? F.e.我不希望 mapstruct 将
id
字段从 carDto
映射到 car
实体,如果我不定义主体并手动跳过 id
字段映射,mapstruct 将执行此操作。 使用
@Mapping( target = "id", ignore = true )
。
如果使用 (nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE) 尝试@Mapping(源=“id”,目标=“id”,忽略= true)