Paul N
05/30/2025, 12:40 PMcontext.initializer.classes: mypackage.BeansInitializer
So instead I've used META-INF/spring.factories:
org.springframework.context.ApplicationContextInitializer=\
mypackage.BeansInitializer
and my application breaks.
The issue is that in my BeansInitializer class I'm using ref() to inject a bean that is created via an @Component annotation in a jar file.
The trouble is that now the initalizer seems to run before it's dependent bean is created, so I get a message like this:
A component required a bean of type 'Whatever' that could not be found.
How do correctly use the kotlin beans DSL in Spring 3.4.5 ?
NB I can't modify the main function to add the initializer that way as that only works for the main application, not tests, and I don't want to add the initializer to loads of integration tests either.Paul N
05/30/2025, 1:36 PMhantsy
06/13/2025, 12:53 AMfun main(args: Array<String>) {
runApplication<DemoApplication>(*args) {
addInitializers(beans())
}
}
Check my example https://github.com/hantsy/spring-reactive-sample/blob/master/boot-kotlin-dsl/src/main/kotlin/com/example/demo/DemoApplication.kt