1、spring Bean的做用域:scope=singleton(默認,單例,生成一個實例)spring
<bean id="bean4" class="com.zd.bean.Bean4" scope="singleton" > //或不配
<property name="age">
<value>18</value>
</property>
</bean>spa
2、spring Bean的做用域:scope=prototype prototype
<bean id="bean4" class="com.zd.bean.Bean4" scope="prototype" > <property name="age">
<value>18</value>
</property>
</bean>作用域
scope指定爲prototype,每次getBean時都會new一個實體出來get