Sobes.tech
Junior — Middle

How often is a Prototype Bean instance created when used as a dependency for a Singleton Bean?

sobes.tech AI

Answer from AI

When using a Prototype Bean as a dependency for a Singleton Bean in the Spring Framework, the Prototype instance is created only once during the initialization of the Singleton. This means that the Prototype Bean is not recreated on each call, but is injected once and reused within the Singleton. To obtain a new Prototype instance each time, special methods such as ObjectFactory or Provider should be used, which allow requesting a new Prototype Bean dynamically.

How often is a Prototype Bean instance created when… - sobes.tech