- Building Microservices with Spring
- Dinesh Rajput Rajesh R V
- 86字
- 2021-07-02 14:54:01
Implementing the Factory design pattern in Spring Framework
Spring Framework transparently uses this Factory design pattern to implement Spring containers using BeanFactory and ApplicationContext interfaces. Spring's container works based on the Factory pattern to create spring beans for the Spring application and also manages the life cycle of every Spring bean. BeanFactory and ApplicationContext are factory interfaces, and Spring has lots of implementing classes. The getBean()method is the factory method that gives you Spring beans accordingly.
Let's see a sample implementation of the Factory design pattern.