获取springmvc中spring当前容器

@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();
        }

你可能感兴趣的:(获取springmvc中spring当前容器)