P
P
Pavel Talaiko2018-10-30 13:23:13
Java
Pavel Talaiko, 2018-10-30 13:23:13

Why is mapstruct not always @Autowired field?

@Mapper(componentModel = "spring", uses = Converters.class, injectionStrategy = InjectionStrategy.FIELD)
public interface ObjectInfoMapper { 
}

@Mapper(componentModel = "spring", uses = Converters.class, injectionStrategy = InjectionStrategy.FIELD)
public interface ObjectMapper {
}

After generating such files
@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2018-10-30T12:17:47+0300",
    comments = "version: 1.3.0.Beta1, compiler: javac, environment: Java 1.8.0_181 (Oracle Corporation)"
)
@Component
public class ObjectInfoMapperImpl implements ObjectInfoMapper {

    @Autowired
    private Converters converters; // есть поле
}

/*
Второй 
*/
@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2018-10-30T12:35:34+0300",
    comments = "version: 1.3.0.Beta1, compiler: javac, environment: Java 1.8.0_181 (Oracle Corporation)"
)
@Component
public class CvInfoMapperImpl implements ObjectMapper {
// Нет поля @Autowired
}

Why can this happen?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question