上一节,我们学习了SpringBean的依赖注入方式,以及它是如何解决循环依赖的问题,今天我们一起来看下SpringBean的作用域问题。话不多说,直接上干货。
关于Springbean的作用域配置方式举例如下,通过scope属性指定具体值。
beanid="student"class="model.Student"scope="singleton"/bean
Springbean的作用域共有六个,分别是singleton,prototype,request,session,application,websocket,下图是Spring