MapStruct 的 @BeanMapping 和 @Mapping 的不同

MapStruct 的 @BeanMapping 和 @Mapping 的不同

@MappingMapStruct 的核心注解,用于定义不同名字的属性之间的映射。

JavaDoc:
Configures the mapping of one bean attribute.
配置一个 bean 属性的映射

@BeanMapping 用于控制整个映射方法。你可以通过设置 @BeanMappingNullValueCheckStrategy 使整个方法都生效。

JavaDoc:
Configures the mapping between two bean types
配置两个 bean 类型的映射

参考:

  1. MapStruct: Difference between BeanMapping and Mapping
作者

Jakes Lee

发布于

2020-05-02

更新于

2021-11-18

许可协议

评论