使用WebApplicationContextUtils来获取WebApplicationContext
WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(ServletActionContext.getServletContext());
IUserServiceWs serviceWs = ctx.getBean("checkTokenService", IUserServiceWs.class);
通过ClassPathXmlApplicationContext加载applicationContext.xml文件来获取cxf
ClassPathXmlApplicationContext cxf = new ClassPathXmlApplicationContext("/applicationContext.xml");
IHelloService helloService = cxf.getBean("helloService",IHelloService.class);
通过Resource获取FactoryBean(XmlBeanFactory已过时)
Resource resource = new ClassPathResource("applicationContext.xml");
BeanFactory beanFactory = new XmlBeanFactory(resource);
HelloWorld helloWorld = beanFactory.getBean("hello",HelloWorld.class);