Does every time I new an new BeanFactory the beans in the XML file are to be recreated? In other words, if I set an bean's scope to Singleton, I got the same Object even if I newed another BeanFactory?
Summary: yes, for one BeanFactory
, no, for creating a BeanFactory
each time.
If you use scope="singleton"
, which is the default setting, you will get the same instance each time from the same BeanFactory
.
Spring does not manage scope across multiple, unrelated, BeanFactory instances.
Why you would create multiple bean factories?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With