When Spring instantiates a bean, there are two situations
first: If you use BeanFactory as the factory class of Spring Bean, all beans are instantiated when the bean is used for the first time.
Second: if you use As the factory class of Spring Bean, ApplicationContext is divided into the following situations:
(1): If the scope of the bean is singleton and lazy-init is false (the default is false, so it is not necessary to set it), then ApplicationContext starts Instantiate the bean at any time, and put the instantiated bean in the cache of a map structure. The next time the bean is used, it will be taken directly from the cache
(2): if the scope of the bean is singleton, and If lazy-init is true, the instantiation of the bean is instantiated when the bean is used for the first time
(3): If the scope of the bean is prototype, the instantiation of the bean is instantiated when the bean is used for the first time. Bean instantiation
When is spring's bean instantiated?
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324441314&siteId=291194637
Ranking