标签:style blog color io ar div log new
1. WebApplicationContext wac = ContextLoader.getCurrentWebApplicationCon;
2. ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
3.
public class Springfactory implements BeanFactoryAware { private static BeanFactory beanFactory; // private static ApplicationContext context; public void setBeanFactory(BeanFactory factory) throws BeansException { this.beanFactory = factory; } /** * 根据beanName名字取得bean * * @param beanName * @return */ public static <T> T getBean(String beanName) { if (null != beanFactory) { return (T) beanFactory.getBean(beanName); } return null; } }
标签:style blog color io ar div log new
原文地址:http://www.cnblogs.com/dingyingsi/p/3909194.html