linpeilie / mapstruct-plus

MapStruct Plus is an enhancement to the MapStruct framework. It can automatically generate the transformation operation between two classes through an annotation, omitting the operation of defining the interface of MapStruct, makes Java type conversion easy and elegant.
https://mapstruct.plus/
Apache License 2.0
274 stars 22 forks source link

泛型上界问题 #78

Closed wzkris closed 5 months ago

wzkris commented 6 months ago

image 1712990300295 但是生成的代码报错,如下 image 但是我用set编译器就不会报错

linpeilie commented 6 months ago

这个是mapstruct处理集合默认策略的问题。

MapStruct 提供的解决方案是在 Mapper 注解中,配置 collectionMappingStrategy = CollectionMappingStrategy.TARGET_IMMUTABLE。 但 MapStructPlus 的 AutoMapper 注解暂时没有增加该配置项。

可以通过如下方式临时解决:

自定义两个转换接口:

这样子可以临时解决该问题,下个版本增加 collectionMappingStrategy 配置项

linpeilie commented 6 months ago

增加自定义转换接口后,LoginUserLoginUserVOAutoMapper 注解需要去掉

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 5 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.