获取springmvc中spring当前容器

2018-10-25  本文已影响30人  小超人爱小土豆
@RequestMapping(value="/Resync", method = RequestMethod.GET)
    public  void resync(HttpServletRequest request){
        try {
            logger.error("-------------开始执行手动同步--------");
            WebApplicationContext springContext = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
            SyncJob job = (SyncJob)springContext.getBean("syncJob");
            job.execute();
            logger.error("-------------手动同步执行结束--------");
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
上一篇下一篇

猜你喜欢

热点阅读