mapstruct错误:Ambiguous mapping methods found for mapping collection element
程序员文章站
2022-03-01 13:37:26
...
如果是list,用 @IterableMapping(qualifiedByName = “toListDto”) 指定名称即可。
用qualifiedByName指定映射方法,官网代码如下:
@Named("EnglishToGerman")
public String translateTitleEG(String title) {
// some mapping logic
}
@Named("GermanToEnglish")
public String translateTitleGE(String title) {
// some mapping logic
}
@Mapping( target = "title", qualifiedByName = { "TitleTranslator", "EnglishToGerman" } )
GermanRelease toGerman( OriginalRelease movies );