解释 Spring 支持的几种bean的作用域。
- singleton:bean 在每个Spring ioc容器中只有一个实例。
- prototype:一个bean的定义可以有多个实例。
- request:每次http请求都会创建一个bean,该作用域仅在基于web的Spring ApplicationContext情形下有效。
- session:在一个HTTP Session中,一个bean定义对应一个实例。该作用域仅在基于web的SpringApplicationContext 情形下有效。
- global-session:在一个全局的HTTP Session中,一个bean定义对应一个实例。该作用域仅在基于web的SpringApplicationContext 情形下有效。缺省的Spring bean的作用域是Singleton.