Spring框架支持以下五種bean的作用域:
singleton :bean在每個Spring ioc 容器中只有一個實例。
prototype:一個bean的定義可以有多個實例。
request:每次http請求都會創建一個bean,該作用域僅在基於web的Spring ApplicationContext情形下有效。
session:在一個HTTP Session中,一個bean定義對應一個實例。該作用域僅在基於web的Spring ApplicationContext情形下有效。
global-session:在一個全局的HTTP Session中,一個bean定義對應一個實例。該作用域僅在基於web的Spring ApplicationContext情形下有效。
缺省的Spring bean 的作用域是Singleton.
