Holooly Plus Logo

Input / Question:

Input / Question:

What are singleton beans and how can you create prototype beans?

Verified

Output/Answer

Beans defined in spring framework are singleton beans. There is an attribute in bean tag named ‘singleton’ if specified true then bean becomes singleton and if set to false then the bean becomes a prototype bean. By default it is set to true. So, all the beans in spring framework are by default singleton beans.

<beans>

<bean id="bar" class="com.act.Foo" singleton=”false”/>

</beans>