当前位置: 代码迷 >> java >> 在JAX-WS Web服务中启用SpringBeanAutowiringSupport时出错
  详细解决方案

在JAX-WS Web服务中启用SpringBeanAutowiringSupport时出错

热度:36   发布时间:2023-07-17 20:47:06.0

我试图在我的webservice中启用Spring自动装配支持,遵循以下几行

public class MyService extends SpringBeanAutowiringSupport implements SomeInterface {

private Dao dao;

@Autowired
public void setDao(Dao dao) {
    this.dao = dao;
}

使用MyService类注释

@WebService(endpointInterface = "SomeInterfacePath")

但是,当我尝试运行它时,我得到了一个

java.lang.NoSuchMethodError: org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext()Lorg/springframework/web/context/WebApplicationContext;
at org.springframework.web.context.support.SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(SpringBeanAutowiringSupport.java:81)
at org.springframework.web.context.support.SpringBeanAutowiringSupport.<init>(SpringBeanAutowiringSupport.java:68)

错误,我无法找到解决方案。 我正在使用Spring 3.0 jar和apache-cxf。 Spring自动装配在我??的项目的其他地方工作,但似乎在这里不能很好地发挥作用。 关于发生了什么的任何想法? 我在appConfig中定义了一个jaxws端点

<jaxws:endpoint 
    id="myendpoint" 
    implementor="MyService" 
    address="/helloworld
    />

直到最近,Apache CXF还将Spring 2.5.5作为maven依赖。 但是,CXF 2.3版和更新版使用Spring 3。

  •  <spring.version>2.5.5</spring.version> 
  •  <spring.version>3.0.4.RELEASE</spring.version> 

两者都包含一个<dependencymanagement>部分,它将Spring与指定的版本联系起来。

  相关解决方案