简体   繁体   中英

Lifetime of object created using ApplicationContext.xml in Spring MVC

I am new to spring application...

I want to know, When the object created using applicationcontext.xml file will get destroyed?..

ie, I want to know the life time of the object created by applicationcontext.xml file...

I tried a lot in Google search but I can't able to find out solution.. All suggestions are towards the Scope of bean.. Is that scope determines the lifetime?

How to find out lifetime of object and when ll it get destroyed in Spring MVC?...

Thanks in advance and expects to get resolve soon... Please help me out..

Spring will destroy the objects (only Singletons) when the applicationContext is closed.

From Doc

A BeanFactory is supposed to invoke the destroy method if it disposes a cached singleton. An application context is supposed to dispose all of its singletons on close.

Comment from Spring Team member

One thing to note is that Spring doesn't track prototypes/scoped beans - it only tracks singletons and as a result, the destroy method will be called only on singletons.

Source : http://forum.springsource.org/showthread.php?32253-When-will-the-bean-s-destroy-method-be-invoked

Yes scope determines the lifetime. Look at the different bean scopes available

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM