通过类名直接获取某个spring对象

来源:互联网 发布:aide表白源码 编辑:程序博客网 时间:2024/05/21 10:32
@SuppressWarnings("unchecked")public static <T> T getBean(String name) {return (T) ContextLoader.getCurrentWebApplicationContext().getBean(name);}
public static TradeService getDao(){
if(tradeService==null){
tradeService = SpringUtil.getBean("tradeService");
}
return tradeService;
}
阅读全文
0 0
原创粉丝点击