关于java:Spring-bean的作用域

bean的作用域

scope标签属性:

  • singleton单例模式

    <bean id="address" scope="singleton" class="com.spring.pojo.Address"></bean>

    每次取到的bean都是同一个对象。

  • prototype原型模式

    <bean id="address" scope="prototype" class="com.spring.pojo.Address"></bean>

    每次取到不同的对象。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理