要从JAX-WS Web服务中访问ApplicationContext,您可以采用以下步骤:
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class MyWebServiceImpl implements MyWebService, ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
// 在JAX-WS Web服务的实现方法中使用applicationContext
public void myWebServiceMethod() {
// 使用applicationContext获取其他Bean
MyBean myBean = applicationContext.getBean(MyBean.class);
myBean.doSomething();
}
}
推荐的腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云