Hello,
I am in the middle of learning spring in an online course and one of the course parts uses MapStruct.
Unfortunately I fail to start spring boot because of failed dependency (Bean cannot be injected because no impl was found).
I looked into generated sources and it turns out that MapperImpl has a missing @Component annotation. The course instructor also showed generated source of the mapper which had @Component attached to the implementation.
The branch that is causing the problem: category-controller
My OS: win10
IDE: idea pro 2017.3
MapStruct ver: 1.2.0.Final
The generated code I get:
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2018-03-22T22:24:43+0100",
comments = "version: 1.2.0.Final, compiler: javac, environment: Java 1.8.0_131 (Oracle Corporation)"
)
public class CategoryMapperImpl implements CategoryMapper {
@Override
public CategoryDTO categoryToCategoryDTO(Category category) {
if ( category == null ) {
return null;
}
CategoryDTO categoryDTO = new CategoryDTO();
categoryDTO.setId( category.getId() );
categoryDTO.setName( category.getName() );
return categoryDTO;
}
}
I checked the documentation and seems everything is correctly setup in pom (well, the instructor used the same code and it works on his side).
How can I force Mapper implementation to have @Component annotation?