Здравствуйте. Я новичок в Kotlin и Spring, который пытается зарегистрировать именованный компонент в контексте приложения, как показано в Регистрация функциональных компонентов Spring 5 . Однако подпись функции не совпадает. Любая помощь приветствуется. Я получаю следующую ошибку: Ошибка подписи функции
Вот текстовая версия ошибки:
None of the following functions can be called with the arguments supplied:
public final fun <T : Any!> registerBean(p0: Class<(???..???)>, p1: () -> (???..???), p2: Array<(out) BeanDefinitionCustomizer!>): Unit defined in org.springframework.web.context.support.GenericWebApplicationContext
public final fun <T : Any!> registerBean(p0: Class<(???..???)>, p1: Supplier<(???..???)>, vararg p2: BeanDefinitionCustomizer!): Unit defined in org.springframework.web.context.support.GenericWebApplicationContext
public final fun <T : Any!> registerBean(p0: Class<(???..???)>, vararg p1: BeanDefinitionCustomizer!): Unit defined in org.springframework.web.context.support.GenericWebApplicationContext
public open fun <T : Any!> registerBean(@Nullable p0: String?, p1: Class<Long!>, @Nullable p2: Supplier<Long!>?, vararg p3: BeanDefinitionCustomizer!): Unit defined in org.springframework.web.context.support.GenericWebApplicationContext
public final fun <T : Any!> registerBean(@Nullable p0: String?, p1: Class<Long!>, vararg p2: BeanDefinitionCustomizer!): Unit defined in org.springframework.web.context.support.GenericWebApplicationContext
Вот код, в котором я регистрирую bean-компоненты:
@Service
class DummyClass {
@Autowired
lateinit var applicationContext: GenericWebApplicationContext
fun dummyFunc(cluster: ElasticsearchCluster) {
val context = SnapshotContext(cluster)
applicationContext.registerBean("${cluster.getName()}SnapshotStartTime", Long::class, { System.nanoTime() })
applicationContext.registerBean("${cluster.getName()}SnapshotContext", SnapshotContext::class, { context })
}
}