我知道我可以创建一个这样的映射器:
@Mapper(componentModel="spring")
public interface MyMapper{
这将导致:
@Component
public class MyMapperImpl{
如何设置获取的bean名称:
@Component("name")
public class MyMapperImpl{
目前不支持此功能。这是为此功能请求的问题 mapstruct/mapstruct#1427。
根据您的名称的外观,您可以使用自定义
AnnotationBeanNameGenerator
来生成组件扫描的映射器。
从 MapStruct 1.6(1.6.0.Beta1 已经发布)开始,可以使用新的
@AnnotateWith
例如
@AnnotateWith(value = Service.class, elements = @Element(strings = "myMapperV2")
@Mapper(componentModel="spring")
public interface MyMapper {
// ...
}