`
liuxiang123
  • 浏览: 29745 次
  • 性别: Icon_minigender_1
  • 来自: 四川
社区版块
存档分类
最新评论

不重启服务器刷直接新spring的bean配置

阅读更多

在生产系统中我们发布程序有时候会漏发spring的配置文件,我们又不想重新启动服务器因此可以用改方法进行刷新。

 

我们可以再管理页面中提供一个刷新context文件按钮进行刷新。

 

采用的方法为:

 

public final class WebUtil {

  public static ConfigurableWebApplicationContext getConfigurableWebApplicationContext(ServletContext sc){
          ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext)WebApplicationContextUtils
         .getRequiredWebApplicationContext(sc);
         return ctx;
     }
}
ServletContext context = request.getSession().getServletContext();
ConfigurableWebApplicationContext cwc = WebUtil.getConfigurableWebApplicationContext(context);
cwc.refresh();

  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics