旧版本了,在xml中定义才有的。其实现在基于注解都没怎么折腾这个的了。
Scope | 说明 |
---|---|
singleton | (默认)每个 Spring IoC 容器将单个 Bean 定义的 Scope 指定为单个对象实例。 |
prototype | 将单个 Bean 定义的 Scope 扩大到任意数量的对象实例。 |
request | 将单个 Bean 定义的 Scope 扩大到单个 HTTP 请求的生命周期。也就是说,每个 HTTP 请求都有自己的 Bean 实例,该实例是在单个 Bean 定义的基础上创建的。只在 Web 感知的 Spring ApplicationContext 的上下文中有效。 |
session | 将单个 Bean 定义的 Scope 扩大到一个 HTTP 会话的生命周期。只在 Web 感知的 Spring ApplicationContext 的上下文中有效。 |
application | 将单个 Bean 定义的 Scope 扩大到 ServletContext 的生命周期中。只在 Web 感知的 Spring ApplicationContext 的上下文中有效。 |
websocket | 将单个 Bean 定义的 Scope 扩大到 WebSocket 的生命周期。只在 Web 感知的 Spring ApplicationContext 的上下文中有效。 |

发表回复