方法一:http://blog.sina.com.cn/s/blog_6ec6be0e0101h59l.html
代码二:
package com.taobao.ddsellmanage.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class ContextConf implements ApplicationContextAware{
static ApplicationContext context = null ;
public void setApplicationContext(ApplicationContext appcontext) throws BeansException {
context = appcontext ;
}
public static ApplicationContext getContext() {
return context;
}
public static void setContext(ApplicationContext appcontext) {
context = appcontext;
}
public static Object getBean(String beanName) {
return getContext().getBean(beanName);
}
}
<bean class="com.taobao.ddsellmanage.util.ContextConf" />