Spring beans, life cycle in XmlWebApplicationContext (web context)

I have already found a previous question SF regarding this issue, and I think that set properties init-methodand destroy-methodwill be sufficient. But I would hope to ask the question in a different way for further understanding.

If I understand things correctly, the class that implements org.springframework.context.Lifecyclewill differ in the context of the web application (namely org.springframework.web.context.support.XmlWebApplicationContext) than in other contexts of the application? This will be done because start() XmlWebApplicationContext(which will start Lifecycle beans) will be executed before the context configuration files are loaded.

Is it correct?

+3
source share
2 answers

Lifecycle beans, . (. docs ), beans , , / .

start() stop() - , , , .

, . - , . , - (, ), bean .

+1

. start() doStart() AbstractApplicationContext, . .

+1

Source: https://habr.com/ru/post/1733996/


All Articles