Is spring default scope singleton or not?

前端 未结 8 734
悲哀的现实
悲哀的现实 2020-11-28 08:17

Could you please explain why Spring is creating two objects for the configuration of beans shown below, since by default spring default scope is singleton?

The Sprin

8条回答
  •  佛祖请我去吃肉
    2020-11-28 08:23

    You're confusing two different concepts.

    The word singleton in spring is used for a bean scope, meaning that the bean will be created only once for the whole application.

    Singleton usual meaning refers to the GOF pattern. It is an object oriented pattern guarantying that only one instance of a class will exists (at least in the scope of the classLoader).

提交回复
热议问题