现在的项目结构是这样的
项目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>
然后就好了,还是不知道为什么这样就好了