Spring中bean的作用域

(1)Singleton:单例bean。

(2)prototype:多例bean。每次请求都会创建一个bean。

(3)request:每次http请求都会创建一个bean,该bean仅在当前http request内有效。

(4)session:在一个HTTP Session中,一个Bean定义对应一个实例。该作用域仅在基于web的Spring ApplicationContext情形下有效。

(5)global-session:全局session作用域,仅仅在基于portlet的web应用中才有意义。

posted @ 2023-05-29 11:07  程序员_YHB  阅读(16)  评论(0)    收藏  举报