在IoC容器中创建的对象能否称为Singleton。如果没有-为什么? [英] Can the object created in IoC container be called Singleton. If not - why?

查看:58
本文介绍了在IoC容器中创建的对象能否称为Singleton。如果没有-为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可以,那么可以在IOC容器中创建的对象称为Singleton吗?

can the object created in IOC container can be called Singleton if yes why if no why?

有人可以用简单的语言详细解释一下IOC容器如何精确地管理我吗?这些对象。

Can anybody explain me in detail in simple words how IOC conatiner exactly manages the objects..

推荐答案

您可以说弹簧单例不是单例。

You can say that a spring singleton is not a singleton.

Singleton具有有意义的作用域,spring单例作用域是spring ioc容器。经典的单例有意义的作用域是ClassLoader。您可以在此处找到有关这些单例之间的区别的更多信息: Spring单例不是单例

Singleton has its meaningful scope, the spring singleton scope is the spring ioc container. And the classic singleton's meaningful scope is the ClassLoader. You may find more about the distinction between these kinds of singleton here: A spring singleton is not a singleton.

Spring在hashmap(Singleton缓存)中管理其单例。当您从spring ioc容器中获取一个bean时,它将首先检查该bean是否已存在于单例缓存中,如果存在,它将从单例缓存中返回该bean。

Spring manage its singleton in a hashmap(Singleton Cache). When you get a bean from the spring ioc container, it first checks if the bean has already exists in the singleton cache, if does, it returns the bean from the singleton cache

这篇关于在IoC容器中创建的对象能否称为Singleton。如果没有-为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆