digdeep

凡是过去,皆是序幕。Read the fucking manual and source code.

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

有个特殊需求,一个普通的类,定时任务,需要获取SpringMVC的controller对应的bean:

方法:

WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
        FluController fluController = (FluController) wac.getBean("fluController");
        if(fluController == null){
            logger.error(" fluControler is null !!!!!!");
            return;
        }

如果报错,找不到bean fluController,那么就把这个controller配置到 applicationContext.xml中即可。

 

posted on 2019-12-05 15:42  digdeep  阅读(2397)  评论(0编辑  收藏  举报
不懂数据库和Web安全的架构师不是一个好的程序员。