小菜鸟学 Spring-bean scope (一)

来源:互联网 发布:常见网络诈骗 编辑:程序博客网 时间:2024/04/28 07:14
this information below just for study record of mine.

默认情况下:Spring 创建singleton bean 以便于错误能够被发现。
延迟加载:延迟加载可以使bean 在被需要的时候实例化

Bean Scope
singleton :    Scopes a single bean definition to a single object instance per Spring IoC container.
To put it another way, when you define a bean definition and it is scoped as a singleton, the Spring IoC container creates exactly one instance of the object defined by that bean definition. This single instance is stored in a cache of such singleton beans, and all subsequent requests and references for that named bean return the cached object.



prototype:    Scopes a single bean definition to any number of object instances
request:         Scopes a single bean definition to the lifecycle of a single HTTP request
session:  Scopes a single bean definition to the lifecycle of an HTTP Session
global session: Scopes a single bean definition to the lifecycle of a global HTTP Session


this come from http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/beans.html#beans-factory-scopes
if there are some copyright or problem happened ,please contact  me.
zbwork000@163.com



原创粉丝点击