axis生成的webservice自动注入无效
使用Spring的自动注入功能非常方便,但其非常依赖配置文件,本次遇到的问题是基于axis生成的webservice中自动注入无效,本质原因是外部请求webservice经过的servlet不是Spring,从而使得配置文件未读取。
解决方法是在需要执行的webservice中手动读取一下Spring的配置文件即可:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
如果仍存在问题可以在applicationContext.xml文件中配置一个bean,然后在读取完配置文件后主动获取一下即可:
AutowiredService autowiredService = (AutowiredService) context.getBean("autowiredService");

浙公网安备 33010602011771号