Singleton Class Vs Singleton bean scope
I have seen people getting confused between singleton scope vs singleton design pattern. Basically, there is a bit difference between these two. Singleton scope: The spring support five different scopes and it is used to decide which type of bean instance should be returning from Spring container back to the caller. One of the scope is Singleton and the by default scope too. It returns a single bean instance per Spring IoC container. <bean id=”object1” class=“com.package.classname”/> When I said, single bean instance per spring Ioc Container i.e. you will always get the same object regardless of the number of call of the same bean but if you declare another bean for the same class then you will get another object for another bean. Let’s understand this with an example: <bean id=”object1” class=“com.package.classname”/> <bean id=”object2” class=“com.package.classname” scope=”prototype”/> <bean id=”object3” class=“com.package.classname”/...