Hello! How do I create a Spring like bean? I don'...
# kodein
c
Hello! How do I create a Spring like bean? I don't have an interface to bind with its implementation. I just need the instance available at kodein container. I went through documentation, but I couldn't find anything similar. Thanks in advance!
r
Spring beans are just classes bound into the Spring container, With Kodein you just need to bind your instance into the kodein container aswell, like:
Copy code
bind<DataSource>() with singleton { MyBean() }
as explained here https://kodein.org/Kodein-DI/?6.2/core#_singleton_binding or https://kodein.org/Kodein-DI/?6.2/core#_direct_binding retrieving dependencies is also easy, depending on the model you chose (injection / retrieval) https://kodein.org/Kodein-DI/?6.2/core#_dependency_injection_retrieval
👍 1
c
Thanks a lot @romainbsl!