11

以下のようなマッピングを作成します。(street、city など) のようなフラットな dto オブジェクト プロパティをドメイン オブジェクトのネストされたアドレスにマップする方法。しようとすると、エラーが発生しました:

[エラー] 診断: 戻り値の型に不明なプロパティ "address.postalCode" があります。@Mapping(source = "city", target = "address.city"),

@Mapper(componentModel = "spring", uses = {})
public interface CompanyMapper {
    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "street", target = "address.street"),
            @Mapping(source = "city", target = "address.city"),
            @Mapping(source = "postalCode", target = "address.postalCode"),
            @Mapping(source = "province", target = "address.province"),
    })
    DomainObject map(DtoObject dto);

そして授業...

public class Address {
            private String street;
            private Integer streetNumber;
            private String city;
            private String postalCode;
            private String province;
            //getters and setters
    }
public class DomainObject {
        private String id;
        private Address address;
        //getters and setters
}

public class DtoObject {
        private String id;
        private String street;
        private String city;
        private String postalCode;
        private String province;
        //getters and setters
}
4

2 に答える 2