###No qualifying bean of type [cn.e3.manager.service.ItemCatService] ,web注入service失败

来源:互联网 发布:提升网络安全意识 编辑:程序博客网 时间:2024/06/05 02:22


====【一直以为是和之前一样:是 ①注解没写,②Spring配置没有扫描service包的问题】

===找啊找找不到:

还好有源码可参考,发现是dubbo服务 配置文件 ,写错了。【忘记在web端添加 引用dubbo服务】

===和dubbo,初次见面,送个bug不成敬意。。。

正确:

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://code.alibabatech.com/schema/dubbohttp://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util-4.0.xsd"><!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 --><dubbo:application name="manager-web" /><!-- 使用multicast广播注册中心暴露发现服务地址 --><dubbo:registry address="zookeeper://192.168.108.128:2181" /><!-- 生成远程服务代理,可以和本地bean一样使用demoService --><!-- 商品服务 --><dubbo:reference id="itemService"interface="cn.e3.manager.service.ItemService" timeout="1000000" retries="2"/><!-- 商品类别服务 --><dubbo:reference id="itemCatService"interface="cn.e3.manager.service.ItemCatService" timeout="1000000" retries="2"/></beans>

错误的:

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsdhttp://code.alibabatech.com/schema/dubbohttp://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc-4.0.xsdhttp://www.springframework.org/schema/utilhttp://www.springframework.org/schema/util/spring-util-4.0.xsd"><!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 --><dubbo:application name="manager-web" /><!-- 使用multicast广播注册中心暴露发现服务地址 --><!-- 我的虚拟机1  ====NAT模式--><dubbo:registry address="zookeeper://192.168.108.128:2181" /> <!-- 我的虚拟机2 克隆 ====桥接模式--><!-- <dubbo:registry address="zookeeper://192.168.167.78:2181" />  --><!-- 生成远程服务代理,可以和本地bean一样使用demoService --><!-- ====【timeout="1000000" retries="2"】解决服务超时问题,默认时间太短。单位毫秒,超时重试2次======= -->   <!-- ====【dubbo的负载均衡】还没体现。===一台服务器超时,dubbo让客户端访问另一台服务器。==== --><!-- <dubbo:reference id="itemService" -->   <!-- interface="cn.e3.manager.service.ItemService" /> --><dubbo:reference id="itemService"interface="cn.e3.manager.service.ItemService" timeout="1000000" retries="2"/></beans>

=======下次就熟悉了。和CXF类似,web service两端都要配置。

但是######  dubbo【每添加一个类都要 修改 两端的服务配置】

====#####【添加类:修改了配置了service,忘记配置了web端】。是我错误原因

====#####【错误提示:普通思路,实在找不到,就思考是否使用了新技术。====新技术运用不熟,常常导致错误。】



阅读全文
0 0
原创粉丝点击