Scope意为“范围”,Spring中通过@Scope注解描述Bean的作用范围,决定Spring容器以什么方式新建Bean。

  

 

 

   @Scope注解中value的取值有:

  1、Singleton - 一个Spring容器中只有一个该Bean的实例,所有使用到该Bean的地方共用一个Bean,value的默认值为Singleton。

  2、Prototype - 每次调用新建一个Bean的实例。

  3、Session - Web项目中,给每一个http session新建一个Bean实例。

  4、Request - Web项目中,给每一个http request新建一个Bean实例。