I have the following parts in my gradle file:
(我的gradle文件中包含以下部分:)
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.
(而且我还在使用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?
(有谁知道为什么Spring Boot无法使用这种设置?)
ask by ben l translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…