在 mapstruct 映射器中设置 @component bean 名称

Setting the @component bean name in mapstruct mapper

我知道我可以像这样创建一个映射器:

@Mapper(componentModel="spring")
public interface MyMapper{

这将导致:

@Component
public class MyMapperImpl{

如何设置获取的bean名称:

@Component("name")
public class MyMapperImpl{

目前不支持。这是为此功能请求的问题 mapstruct/mapstruct#1427

根据您的名称的外观,您可以使用自定义 AnnotationBeanNameGenerator 生成组件扫描的映射器。