小编Sar*_*èse的帖子

无法映射属性。考虑声明/实现映射方法。无法生成从不可迭代类型到可迭代类型的映射方法

我似乎无法正确使用mapstruct

@Mapping(target = "products", source = "itemBookType")
SearchBookingResult backToTp(ItemBook itemBook);
Run Code Online (Sandbox Code Playgroud)

运行此代码时,我收到以下错误:

Can't map property "ProductType itemBookType" to "List<ProductOverview> products". Consider to declare/implement a mapping method: "List<ProductOverview> map(ProductType value)".
Run Code Online (Sandbox Code Playgroud)

我在底部添加了以下代码:

List<ProductOverview> map(ProductType value);
Run Code Online (Sandbox Code Playgroud)

但它仍然返回以下错误:

Can't generate mapping method from non-iterable type to iterable type from java stdlib.
Run Code Online (Sandbox Code Playgroud)

物品簿类别:

public class ItemBook {
    private ProductType itemBookType; //ProductType class
    private Integer idref;
    private String reference;
}
Run Code Online (Sandbox Code Playgroud)

产品类型类别:

public enum ProductType {
    BOOK, PHONE, GAME
}
Run Code Online (Sandbox Code Playgroud)

搜索预订结果类:

public class SearchBookingResult extends BaseResponse<SearchBookingResult> {
    private …
Run Code Online (Sandbox Code Playgroud)

java mapping spring spring-boot mapstruct

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

mapping ×1

mapstruct ×1

spring ×1

spring-boot ×1