i converted java spring boot codes to kotlin, now i have error in map struct interface and bean config class
This is my Mapper interface
@Component
@Mapper
interface PersonMapper {
fun toPerson(personDTO: PersonDTO?): Person?
fun toPersonDTO(person: Person?): PersonDTO?
fun toPersons(personDTOS: List<PersonDTO?>?): List<Person?>?
fun toPersonDTOs(personList: List<Person?>?): List<PersonDTO?>?
companion object {
@JvmStatic
val INSTANCE: PersonMapper = Mappers.getMapper(PersonMapper::class.java)
}
}
and my Bean Config
@Configuration
class BeanConfig {
@Bean
@Primary
fun personMapper(): PersonMapper {
return PersonMapper.INSTANCE
}
}
and my error
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'personController' defined in file [D:\Zaban\Server\target\classes\ir\ktcoders\zaban\person\PersonController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'personService' defined in file [D:\Zaban\Server\target\classes\ir\ktcoders\zaban\person\PersonService.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personMapper' defined in class path resource [ir/ktcoders/zaban/config/BeanConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [ir.ktcoders.zaban.person.PersonMapper]: Factory method 'personMapper' threw exception; nested exception is java.lang.ExceptionInInitializerError