Добавить
Уведомления

36.Spring Factory Method | Spring Factory Method Injection

Normally, Spring instantiates a class and performs dependency injection. However, sometimes it may be necessary to instantiate a class via another class (usually called a Factory class). In such a scenario, Spring should not create the class on its own but simply delegate the instantiation to the Factory class. Spring provides a way to delegate class instantiation to another class by using factory-method attribute of bean tag. Essentially, there is a static method defined in the Factory class that creates the instance of the required bean, hence the name factory-method. Below is the GitHub link to download source Code: https://github.com/kishanjavatrainer/SpringBeanFactoryMethod.git

Иконка канала Кодерская академия
12 подписчиков
12+
19 просмотров
2 года назад
5 декабря 2023 г.
12+
19 просмотров
2 года назад
5 декабря 2023 г.

Normally, Spring instantiates a class and performs dependency injection. However, sometimes it may be necessary to instantiate a class via another class (usually called a Factory class). In such a scenario, Spring should not create the class on its own but simply delegate the instantiation to the Factory class. Spring provides a way to delegate class instantiation to another class by using factory-method attribute of bean tag. Essentially, there is a static method defined in the Factory class that creates the instance of the required bean, hence the name factory-method. Below is the GitHub link to download source Code: https://github.com/kishanjavatrainer/SpringBeanFactoryMethod.git

, чтобы оставлять комментарии