在他们的文档中(这里:http ://mapstruct.org/documentation/dev/api/org/mapstruct/AfterMapping.html),他们提到 @AfterMapping 可以与 @Qualifier / @Named 一起使用来过滤,但我不能在任何地方都找不到如何以这种方式实际使用它。
我最好的猜测是像这样使用它:
@Mapper
public abstract class CustomerMapper {
@Named("Test")
public abstract Customer map(CustomerDto dto);
@Named("Test")
@AfterMapping
public void doAfterMapping(@MappingTarget Customer customer) {
//do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
但这似乎没有任何作用(如果我删除了 @Named 注释,它可以工作,但它也用于我不想要的其他方法中)。有谁知道需要如何使用它?