【问题标题】:Error enabling SpringBeanAutowiringSupport within a JAX-WS web service在 JAX-WS Web 服务中启用 SpringBeanAutowiringSupport 时出错
【发布时间】:2011-07-26 01:05:40
【问题描述】:

我正在尝试在我的 web 服务中启用 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
    />

【问题讨论】:

  • 闻起来像春季版本的冲突。确保您只有 Spring 3.0 JAR。检查 CXF JAR 以确保其中没有隐藏 Spring 的副本。
  • 谢谢,原来使用的是旧版本的 Spring 框架 jar,因此发生了冲突。
  • 最好将其添加为答案并接受它,以供该网站的其他用户查看。

标签: java web-services spring jax-ws


【解决方案1】:

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

两者都包含一个 &lt;dependencymanagement&gt; 部分,将 Spring 与指定版本联系起来。

【讨论】:

    猜你喜欢
    • 2011-02-25
    • 2012-03-06
    • 1970-01-01
    • 1970-01-01
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多