Explanation These questions were asked before kotlin hit version 1.0. The language syntax is currently out of date, please follow the official docs.
I play with kotlin and spring DI . I want to use constructor-based dependency injection, so I need to annotate the constructor.
I tried the following approach:
Configuration Import(javaClass<DataSourceConfig>()) public open class AppConfig(dataSource: DataSource) { private val dataSource: DataSource Autowired { this.dataSource = dataSource } } Configuration public open class DataSourceConfig { Bean public open fun dataSource(): DataSource {
}
But that will not work. Is it even possible to annotate a constructor in kotlin?
PS I am using Kotlin M10.1 and Spring 4.1.4
UPDATE: An annotating constructor is possible in kotlin. The problem was that he was not allowed to use constructor-based DI for @Configuration
annotations kotlin
ivstas
source share