加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-16 23:25:31 所属栏目:安全 来源:网络整理
导读:在用 Spring+CXF 开发 webservice 的时候发现一个问题, CXF 监听之后的实现类不能注入 Dao ,在网上查了点别人的资料,解决了问题 首先 Spring 的注入配置还是像一般的 Spring 一样注入 !-- 实例化Hibernate实现DAO -- ???????? beanid="ruleServiceDao" cl
在用 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了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读