views:

2776

answers:

1

When you create a Service bean or Dao bean in your Spring applicationContext.xml file, what is the scope of those beans?

Will every person who accesses the web application use the same instance of the bean, or is the bean instantiated for each user's session?

+5  A: 

By default a bean created in Spring is of scope singleton, so yes each person will access the same instance in those cases. The alternative is to specify the scope as prototype.

More info on this here, sections 3.4.1 and 3.4.2:

http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-factory-scopes-prototype

Jon
Wow! It's right there in the documentation. I don't know how I missed it, but thank you VERY much for pointing me to it.
I Never Finish Anythi