[Sprint] Bean Scope Singleton cs Prototype
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Sprint] Bean Scope Singleton cs Prototype相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章