Spring中bean的作用域

Spring框架支持以下五种bean的作用域:

1.singleton:bean在每个Spring ioc容器中只有一个实例。

2.prototype:一个bean的定义可以有多个实例。

3.request:每次http请求都会创建一个bean,该作用域仅在基于web的Spring ApplicationContext中有效。

4.session:在一个http session中有效。该作用域仅在基于web的Spring ApplicationContext中有效。

5.global-session:在一个全局的http session中,一个bean定义对应一个实例,该作用域仅在基于web的Spring ApplicationContext中有效。

posted @ 2018-01-30 14:57  Taeyang  阅读(157)  评论(0)    收藏  举报