I want to enable lazy initialization for my spring boot application to improve the startup time. But once I do that this causes some problems. E.g. my KafkaListeners are also not initialized and will not receive any messages. Can I enable lazy initialization, but eagerly initialize some specific beans?
CodePudding user response:
By default all beans are initialized eagerly in order to have consistent application context. You could initialize some specific beans lazily with @Lazy
.
CodePudding user response:
To be able to make a specific bean eager initialized, I found the annotation org.springframework.data.repository.cdi.Eager. This made it work for me.