微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CXF WebService+Spring 无法注入问题解决方法

在用 Spring+CXF 开发 webservice 的时候发现一个问题, CXF 监听之后的实现类不能注入 Dao ,在网上查了点别人的资料,解决了问题
首先 Spring 的注入配置还是像一般的 Spring 一样注入


<!-- 实例化Hibernate实现DAO -->

         <beanid="ruleServiceDao" class="com.xxx.dao.extend.impl.RuleServiceDaoImpl"  parent="daoTemplate" />


<!-- DAO的对象注入到service中-->

   <beanid="RuleService"class="com.xxx.service.ruleWebservice.impl.RuleServiceImpl"> 

         <!-- 注入Dao实例 -->

         <propertyname="ruleServiceDao"ref="ruleServiceDao"></property>

    

  </bean>

不过CXF的配置文件要有注意的地方
cxf/webservice.xml

<!-- cxf的配置文件 -->

         <importresource="classpath:meta-inf/cxf/cxf.xml" />

         <importresource="classpath:meta-inf/cxf/cxf-extension-soap.xml" />

         <importresource="classpath:meta-inf/cxf/cxf-servlet.xml" />

 

         <!--注册对外接口 implementor是实现类 address是web service地址 -->

 

         <jaxws:endpointid="ruleService"

                 implementorClass="com.xxx.service.ruleWebservice.RuleService"

                 implementor="#RuleService"address="/ruleService" />

注意这个配置implementorClass就是配置这个service的interface,然后implementor就是去引用spring容器中的RuleService这个bean,这样配置,就能在webservice的实现service中注入dao了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐