I have the following parts in my gradle file:
apply plugin: 'kotlin-kapt'
...
compile("org.mapstruct:mapstruct:1.3.0.Final")
kapt("org.mapstruct:mapstruct-processor:1.3.0.Final")
And am also using JUnit 5.
My mapper looks like:
@Mapper(componentModel = "spring")
interface ModelMapper {
fun convertToDto(forms: Model): DTO
@InheritInverseConfiguration
fun convertToModel(dto: DTO): Model
}
And I'm trying to autowire it similar to such:
@Service
@Transactional
class MyService @Autowired constructor(
private val repository: MyRepository,
private val mapper: ModelMapper
) {
...
}
But when I try to run a test/do a build, I get an error:
...
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type '....ModelMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Does anyone know why Spring Boot isn't working with this kind of setup?