如何关闭Spring ApplicationContext? [英] How to close a spring ApplicationContext?

查看:1342
本文介绍了如何关闭Spring ApplicationContext?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序完成后我想关闭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.

推荐答案

向下转发 ApplicationContext ConfigurableApplicationContext 定义 close() 方法:

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

((ConfigurableApplicationContext)appCtx).close();

这篇关于如何关闭Spring ApplicationContext?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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