I know I can create a mapper like this:
@Mapper(componentModel="spring")
public interface MyMapper{
That will result in:
@Component
public class MyMapperImpl{
How can I set the bean name obtaining:
@Component("name")
public class MyMapperImpl{
This is currently not supported. This is issue mapstruct/mapstruct#1427 requested for this feature.
Depending on how your name should look like you can use a custom AnnotationBeanNameGenerator to generate the mappers that are component scanned.
Starting from MapStruct 1.6 (1.6.0.Beta1 is already released) it is possible to use the new @AnnotateWith
e.g.
@AnnotateWith(value = Service.class, elements = @Element(strings = "myMapperV2")
@Mapper(componentModel="spring")
public interface MyMapper {
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With