记录一下dubbo问题的解决办法

现在的项目结构是这样的

项目L-A下有多个子项目:

L-service是服务实现类的项目

L-outer 是提供对外接口的项目

然后现在服务 studentService是一个dubbo服务,它的接口写在L-outer里面,实现类写在L-service里面。

这个服务类的配置如下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

	<!-- 学生服务 -->
	<dubbo:service registry="zkRegistry" ref="studentService" interface="com.luoyu.service.StudentService" />

</beans>

此时项目G-V要调用L-A项目中的接口,也就引入了L-outer包。

此时G-V的xml配置中如下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd">
     

    <!-- hbp_saas 校验是否获取授权服务-->
    <dubbo:reference id="studentService" interface="com.luoyu.service.StudentService" mock="return null" check="false" registry="zkRegistry"/>

    <bean id="chekcFilter" class="com.luoyu.filter.checkFilter" > 
        <property name="filters">
                   <bean id="studentFilter" class="com.luoyu.filter.StudentFilter">
                       <property name="studentService" ref="studentService"></property>
                       <property name="id"  value="17"></property>
                       <property name="cid" value="szd"></property>
                   </bean>
			   </list>
		</property>
    </bean>
    
   </beans>

我引入了dubbo服务 studentService,同时在filter中引入了我的studentService服务,但是就报了重复的studentService这个错误

duplication bean xx

然后我就把上面那个dubbo引用删掉了,又报

Bean property 'studentService' is not writable or has an invalid setter method.

然后我又在StudentFilter里添加了 studentService的getter setter 

但是还是报duplication bean xx

后来把引用studentSerivce的名字改了,加了前缀,zzStudentService就好了

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://code.alibabatech.com/schema/dubbo
        http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd">
     

    <!-- hbp_saas 校验是否获取授权服务-->
    <dubbo:reference id="zzStudentService" interface="com.luoyu.service.zzStudentService" mock="return null" check="false" registry="platformRegistry"/>

    <bean id="chekcFilter" class="com.luoyu.filter.checkFilter" >
        <property name="urlFilter" ref="urlFilter"></property>
        <property name="filters">
                   <bean id="studentFilter" class="com.luoyu.filter.StudentFilter">
                       <property name="studentService" ref="zzStudentService"></property>
                       <property name="id"  value="17"></property>
                       <property name="cid" value="szd"></property>
                   </bean>
			   </list>
		</property>
    </bean>
    
   </beans>

然后就好了,还是不知道为什么这样就好了

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值