我mapstruct
用于在下面的 DTO 中转换域是正在使用的映射:-
@Mapper(componentModel = "spring", uses = {})
public interface CategoriesMapper {
@Mapping(source = "regionsid.id", target = "regionsid.id")
CategoriesDTO categoriesToCategoriesDTO(Categories categories);
}
public class Categories implements Serializable {
private Regions regionsid;
public Regions getRegionsid() {
return regionsid;
}
public void setRegionsid(Regions regions) {
this.regionsid = regions;
}
}
public class CategoriesDTO implements Serializable {
private RegionsDTO regionsid;
public RegionsDTO getRegionsid() {
return regionsid;
}
public void setRegionsid(RegionsDTO regions) {
this.regionsid = regions;
}
}
public class Regions implements Serializable {
private Long id;
}
public class RegionsDTO implements Serializable {
private Long id;
}
所以我在源端和目标端都有一些结构,但我得到以下错误: -
CategoriesMapper.java:28: error: Unknown property "regionsid.id" in return type.
如果我有 Set
资源 -
private Set<Regions> regions = new HashSet<>();
目标 -
private Set<RegionsDTO> regions = new HashSet<>();
CategoriesMapper.java:36: error: Can't map property "java.util.Set<com.equidity.xboard.service.dto.RegionsDTO> regions" to "java.util.Set<com.equidity.xboard.domain.Regions> regions". Consider to declare/implement a mapping method: "java.util.Set<com.equidity.xboard.domain.Regions> map(java.util.Set<com.equidity.xboard.service.dto.RegionsDTO> value)".`