[Spring] Bean Scope Singleton cs Prototype
2024-09-30 19:04:32
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 {}
最新文章
- B树——算法导论(25)
- getElementsByTagName() 方法
- artdialog
- tomcat的CATALINA_HOME可以不用设置
- 如何有效使用Project(2)——进度计划的执行与监控
- Java基础之访问文件与目录——获取与文件存储有关的信息(GetFileStores)
- bzoj 1034 [ZJOI2008]泡泡堂BNB(贪心)
- Python设计模式——状体模式
- apache asp.net
- Chapter 2. Overview gradle概览
- maven配置spring mvc+hibernate+spring框架
- 列表标题栏添加CheckBox(自定义HanderView的时候实现)
- UML九种图-包图、类图
- R语言数据分析利器data.table包 —— 数据框结构处理精讲
- day16,模块 , 用户管理系统 , 购物车程序 , 分页显示.
- js-webpack自动化构建工具
- DAY16 模块和包的导入
- spring boot 1.x配置,不断完善中
- Redis客户端操作之Jedis
- 008_Node中的require和import