标签:
方式一:web容器运行时获取
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); Two two = (Two)ctx.getBean("twoService");
方式二:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/beans.xml"); Two two = (Two)ctx.getBean("twoService");
标签:
原文地址:http://my.oschina.net/sniperLi/blog/506408