- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 jsf
它获得了 spring 的 ApplicationContext,这意味着我可以用它获得一个 bean。
FacesContext fc = FacesContext.getCurrentInstance();
ServletContext sc = (ServletContext) fc.getExternalContext().getContext();
ApplicationContext applicationContext = org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext(sc);
我的问题是如何获取正在运行的 spring 实例的 ConfigurableApplicationContext。
我希望能够调用 .stop .start 和 .refresh 方法。
或者,如果有任何其他方法可以在正在运行的实例上调用它们,请通知我!
注意:应用中没有main方法。它是一个部署在 glassfish v2.1.1 上的 webApplication。
最佳答案
只需转换到ConfigurableApplicationContext
:
ConfigurableApplicationContext applicationContext =
(ConfigurableApplicationContext)
WebApplicationContextUtils.getWebApplicationContext(sc);
关于java - 从 servlet 获取 Spring ConfigurableApplicationContext 运行时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4723218/
public class Tasker{ ConfigurableApplicationContext context ; public void load(){
当我尝试在 Spring Tool Suite 中创建我的第一个应用程序时,出现以下错误: Multiple markers at this line - The type org.springfra
我在 jsf 调用的方法中有以下代码。 它获得了 spring 的 ApplicationContext,这意味着我可以用它获得一个 bean。 FacesContext fc = FacesCont
我们有一个托管在共享 tomcat 实例上的 Spring 应用程序。 有时我们必须重新加载 spring 应用程序上下文,但不想重新启动 Tomcat 服务器,因为其他应用程序也托管在那里。 正在通
我是 spring boot 的新手,在尝试使用 spring initializer 在 intellij 中构建我的第一个 spring boot 项目 (Maven) 时,在创建项目后运行我的项
我在主方法中遇到了阻塞问题“关闭此“ConfigurableApplicationContext”” public static void main(String[] args) { Spri
我正在学习 spring.io 上的教程使用 spring boot 构建一个 spring 应用程序。 我可以让程序在一台计算机上完美运行。当我在另一台计算机上尝试时,出现以下错误 The type
我的 springboot 应用程序一直在运行,但在运行应用程序时突然出现以下错误。 线程“main”中的异常 java.lang.NoSuchMethodError: org.springframe
我是一名优秀的程序员,十分优秀!