首页 > 其他 > 详细

[Sprint] Bean Scope Singleton cs Prototype

时间:2018-09-02 13:54:12      阅读:209      评论:0      收藏:0      [点我收藏+]

We can define a class to be Singleton or Prototype. If the class was defined as Prototype, then everytime when we use new keyword, it will create a new instance.

 

// Singleton
@Service("customerService")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public class CustomerServiceImpl implements CustomerService {}

// Prototype
@Service("customerService")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class CustomerServiceImpl implements CustomerService {}

 

[Sprint] Bean Scope Singleton cs Prototype

原文:https://www.cnblogs.com/Answer1215/p/9573585.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!