Skip to content
Advertisement

How to close a spring ApplicationContext?

After my application finishes I want to close the spring context.
The relevant code has an ApplicationContext reference but I couldn’t find a close method.

Advertisement

Answer

Downcast your ApplicationContext to ConfigurableApplicationContext which defines close() method:

((ConfigurableApplicationContext)appCtx).close();
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement