How do you get a Spring Bean without Dependency Injection?
📰 Dev.to · Simon Martinelli
Access Spring Beans without dependency injection using ApplicationContext
Action Steps
- Create an instance of ApplicationContext
- Use ApplicationContext to get the desired Spring Bean
- Configure the Spring Bean manually if needed
- Apply the Spring Bean to your non-Spring Bean class
- Test the implementation to ensure correct functionality
Who Needs to Know This
Helps developers who need to use Spring Beans in non-Spring Bean classes, useful for backend engineers and developers working with Spring framework
Key Insight
💡 Use ApplicationContext to access Spring Beans in non-Spring Bean classes
Share This
💡 Access Spring Beans without DI using ApplicationContext!
Key Takeaways
Access Spring Beans without dependency injection using ApplicationContext
Full Article
Sometimes, you want to use a Spring Bean in a class that is not a Spring Bean, but then dependency injection doesn’t work. This article shows a way to get around that limitation.
DeepCamp AI