igor.wojda
02/23/2021, 10:06 PMinit
bean as top-level function? (now this bean does not run)
@SpringBootApplication
class TestServerApplication
fun main(args: Array<String>) {
runApplication<TestServerApplication>(*args)
}
@Bean
fun init(repository: StreamRepository) = ApplicationRunner { _ ->
// Do sth on app start
}
This makes a bean run, but this solution involves a lot of nesting, so wonder if this is necessary 🤔
@SpringBootApplication
class InboxionServerApplication {
companion object {
@JvmStatic
fun main(args: Array<String>) {
runApplication<InboxionServerApplication>(*args)
}
}
@Bean
fun init(repository: StreamRepository) = ApplicationRunner { _ ->
// Do sth on app start
}
}
Tobias Berger
02/26/2021, 8:18 AMJoel
03/01/2021, 10:25 PM@Component
class MyInitThing(repository: StreamRepository) : ApplicationRunner {
...
}