In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container.通过这句话我们能看出来,bean实际上就是被Spring IOC容器实例化、组装、管理的对象。也就是说,创建并且管理对象的事儿不用我们去管了,这些都交由Spring框架的IOC容器去管理,这也就是控制反转的头脑,而bean就是我们注入的对象。而bean什么时间去实例化将不会再写死在步调中,也就是我们不需要将对象实例化,只需要用的时间去拿就行了,这种方式不仅让我们不用再花心思管理对象,而且也能避免我们自己一些错误的实例化对象导致的内存题目。
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) | Powered by Discuz! X3.4 |