本文共 330 字,大约阅读时间需要 1 分钟。
我们常用的scope 有:singleton 和prototype
singleton :spring 容器只创建一个,每次请求Bean时,都是返回其引用
prototype:每次请求Bean时,都返回一个新的实例
Bean 的默认scope是singleton
xml:
需要补充的一点是
被设置为singleton 的Bean在Spring 容器初始化的时候,就开始被创建了
The biggest challenge of a web server is to serve many different web users at the same time — each of whom is requesting different pages.
转载地址:http://loiyb.baihongyu.com/