【问题标题】:Spring beans are not detected in JAX-WS service在 JAX-WS 服务中未检测到 Spring bean
【发布时间】:2012-02-04 09:26:23
【问题描述】:

我正在尝试使用我编写的 JAX-WS CXF Web 服务。对于 spring 自动装配注释 bean,我总是得到 nullPointerException 。但是,在 serverSide over web 中一切正常,但通过 JAX-WS CXF webservice 访问 bean。

我尝试过扩展 SpringBeanAutowiringSupport,但仍然没有运气。我该怎么做。

问候, 阿奇夫

【问题讨论】:

  • 我认为 @WebService 注释类是由 CXF 而不是 Spring 初始化的,并且不是 Spring Container 的一部分。我怎样才能将这些链接在一起。请帮忙!

标签: java spring-mvc jax-ws cxf


【解决方案1】:

我想出了我的答案:)

我必须将此添加到我的applicationContext.xml

<!--Person Service Settings -->
<jaxws:endpoint id="personService"  implementor="#person" address="/personService" />
<bean id="person" class="com.service.PersonServiceImpl" />
<bean id="PersonDAO" class="com.dao.PersonDAOImpl"/>
<!--Person Service Settings -->

【讨论】:

    【解决方案2】:

    您是否在您的web.xml 中添加了 Spring 的 ContextLoaderListener

      <context-param> 
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/beans.xml</param-value>
      </context-param>
    
      <listener> 
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    

    【讨论】:

    • 我确实添加了 contextLoaderlistner,但它没有上下文参数,它们是什么,beans.xml 中应该有什么?
    猜你喜欢
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-13
    相关资源
    最近更新 更多