我有以下 DTO 和域对象。我正在使用 Mapstruct 将域对象复制到 DTO 对象。
public class AddressDomain {
private String street;
private Telephone telephone;
}
public class CompanyDomain{
private String id;
private Address address;
}
public class AddressDTO {
private String street;
private Telephone telephone;
}
public class CompanyDTO{
private String id;
private Address address;
}
使用下面的 Mapper 将域映射到 DTO。我不想将电话属性从域映射到 DTO。怎么做?我尝试在映射忽略中提供嵌套目标属性,但它给出了错误:
public interface CompanyMapper {
//**below line gives error**
@Mapping(target = "address.telephone", ignore=true)
CompanyDTO map(AddressDTO dto);
}