webservice并不归spring管理,所以根本不会注入,使用这种方式 好用的话给个赞
EmUserCertInfoServiceImpl emUserCertInfoService=(EmUserCertInfoServiceImpl)SpringBeanUtils.getBean("emUserCertInfoServiceImpl");
package cn.org.bjca.portal.utils; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Service; @Service public class SpringBeanUtils implements ApplicationContextAware { private static ApplicationContext context; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.context=applicationContext; } public static <T> T getBean(Class<T> requiredType){ if(context==null){ throw new IllegalStateException("spring 环境没有启动!"); } return context.getBean(requiredType); } public static <T> T getBean(String beanName,Class<T> requiredType){ if(context==null){ throw new IllegalStateException("spring 环境没有启动!"); } return context.getBean(beanName,requiredType); } public static ApplicationContext getContext(){ if(context==null){ throw new IllegalStateException("spring 环境没有启动!"); } return context; } }