Spring获取springmvc的controller bean
有个特殊需求,一个普通的类,定时任务,需要获取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中即可。
Spring获取springmvc的controller bean的更多相关文章
- Spring之SpringMVC的Controller(源码)分析
说明: 例子就不举了,还是直接进入主题,本文主要是以SpringMVC的Controller接口为入点,来分析SpringMVC中C的具体实现和处理过程. 1.Controller接口 public ...
- spring项目获取ApplicationContext(能手动从Spring获取所需要的bean)
最流行的方法就是 实现ApplicationContextAware接口 @Component public class SpringContextUtil implements Applicati ...
- Spring 和 SpringMVC 常用注解和配置(@Autowired、@Resource、@Component、@Repository、@Service、@Controller的区别)
Spring 常用注解 总结内容 一.Spring部分 1.声明bean的注解 2.注入bean的注解 3.java配置类相关注解 4.切面(AOP)相关注解 5.事务注解 6.@Bean的属性支持 ...
- paip.spring 获取bean getBean 没有beanid的情况下
paip.spring 获取bean getBean 没有beanid的情况下 spring能自动扫描带有注解的bean文件.. 作者Attilax 艾龙, EMAIL:1466519819@q ...
- SpringMVC自动扫描@Controller注解的bean
若要对@Controller注解标注的bean进行自动扫描,必须将<context:component-scan base-package="包路径.controller"/ ...
- spring 框架通过new Object()获取applicationContext 中的bean方案
工作中,需要手动创建一个对象,但用到了spring容器中对象的业务逻辑,这时候就要去通过获取容器中的对象.这时候,可以通过实例化一个实现了ApplicationContextAware接口的类获取sp ...
- Spring获取ApplicationContext方式,和读取配置文件获取bean的几种方式
转自:http://chinazhaokeke.blog.163.com/blog/static/109409055201092811354236 Spring获取ApplicationContex ...
- spring获取bean的时候严格区分大小写
如题:spring获取bean的时候严格区分大小写 配置文件helloservice.xml中配置: <dubbo:reference id="IInsurance" int ...
- Spring获取bean工具类,可用于在线程里面获取bean
Spring获取bean工具类,可用于在线程里面获取bean import java.util.Locale; import org.springframework.beans.BeansExcept ...
随机推荐
- 201871010111-刘佳华《面向对象程序设计(java)》第十三周学习总结
201871010111-刘佳华<面向对象程序设计(java)>第十三周学习总结 实验十一 图形界面事件处理技术 实验时间 2019-11-22 第一部分:理论知识总结 1.事件源:能够产 ...
- python3.5.3rc1学习十一:字典与模块
#os模块import oscurDir = os.getcwd()print(curDir) os.mkdir("新建") import timetime.sleep(2)os. ...
- python3.5.3rc1学习六:画图
# 可以设置颜色,g代表green, r代表red,y代表yellow,b代表blue# linewidth = 5,设置线条粗细 # label 设置线条名称 ##plt.plot(x,y,'b', ...
- [C2W3] Improving Deep Neural Networks : Hyperparameter tuning, Batch Normalization and Programming Frameworks
第三周:Hyperparameter tuning, Batch Normalization and Programming Frameworks 调试处理(Tuning process) 目前为止, ...
- luoguP4151 [WC2011]最大XOR和路径
题意 这题有点神啊. 首先考虑注意这句话: 路径可以重复经过某些点或边,当一条边在路径中出现了多次时,其权值在计算 XOR 和时也要被计算相应多的次数 也就是说如果出现下面的情况: 我们可以通过异或上 ...
- luoguP4097 [HEOI2013]Segment
题意 李超树板子题. 对每个区间维护该区间中点\(mid\)的最优线段. 插入一个线段: 求出这个线段的斜率和截距,注意特判无斜率的情况,得到\(y=kx+b\). 之后开始在线段树上插入,假设当前节 ...
- Vue 使用数组和对象控制Class
直接上代码: <!doctype html> <html lang="en"> <head> <meta charset="UT ...
- hue框架介绍和安装部署
大家好,我是来自内蒙古的小哥,我现在在北京学习大数据,我想把学到的东西分享给大家,想和大家一起学习 hue框架介绍和安装部署 hue全称:HUE=Hadoop User Experience 他是cl ...
- python yield from (一)
1. yield from 会抛出iterator中所有的值:而yield只是抛出传进来的值,如果是值,就抛出值,如果是iterator对象,抛出iterator对象 def g1(iterable) ...
- 【UOJ#22】【UR #1】外星人(动态规划)
[UOJ#22][UR #1]外星人(动态规划) 题面 UOJ 题解 一道简单题? 不难发现只有按照从大往小排序的顺序选择的才有意义,否则先选择一个小数再去模一个大数是没有意义的. 设\(f[i][j ...