Hi,
Every one.
I use dubbo spring-boot with
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
And in order to decouple with dubbo .
I do not use @Service (com.alibaba.dubbo.config.annotation.Service)
annotation on my serviceImpl class , but add @Component annotation to them.
Then I config the service and refrence in another two xml file as
<dubbo:service interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService"
ref="ecAuthMenuI18nServiceImpl" version="0.5.0" protocol="dubbo"
timeout="5000"></dubbo:service>
<dubbo:reference xmlns=""
interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService" version="0.5.0"
id="ecAuthMenuI18n"></dubbo:reference>
to regist the bean to zookeeper as a service.
Finally I use
@ImportResource(locations = {"classpath:META-INF/dubbo/provider.xml"}) on the
bootstrap class of my springboot application.
Then it works.
But when I config the consumer , a problem happened.
In my application.properties I set a property as
dubbo.consumer.check=false
to skip the exist check of provider
and I need a filter to do some work before a RPC request send,so I configed a
filter on my xml file
<dubbo:consumer filter="UserConsumerFilter"/>
when the application start
2019-03-07 15:23:14.672 WARN 4116 --- [ main]
o.s.b.f.s.DefaultListableBeanFactory : Bean creation exception on non-lazy
FactoryBean type check:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception
is java.lang.IllegalStateException: Duplicate consumer configs:
<dubbo:consumer generic="false" filter="UserConsumerFilter"
id="com.alibaba.dubbo.config.ConsumerConfig" /> and <dubbo:consumer
generic="false" />
I think the first tag is from the xml and the secod tag is from the
application.properties.
then I try to add a id parameter on my xml file like
<dubbo:consumer filter="UserConsumerFilter" id="aaa"/>
the warn info is :
2019-03-07 16:56:32.498 WARN 6504 --- [ main]
o.s.b.f.s.DefaultListableBeanFactory : Bean creation exception on non-lazy
FactoryBean type check:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception
is java.lang.IllegalStateException: Duplicate consumer configs:
<dubbo:consumer generic="false" filter="UserConsumerFilter" id="aaa" /> and
<dubbo:consumer generic="false" />
So I think dubbo can only config one <dubbo:consumer > in a context.
Can we consider to imporve this in the future ?
-----------------------------------------------------------------------------------------------------------------------------------------------------------
我们在使用dubbo的过程中,希望可以很容易的在rpc模式和本地模式之间切换,所以并没有使用dubbo的@service注解和@refrence注解。而是使用@component注解将service的实现类注册到spring
再用额外的xml分别定义dubbo的service和refrence
<dubbo:service interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService"
ref="ecAuthMenuI18nServiceImpl" version="0.5.0" protocol="dubbo"
timeout="5000"></dubbo:service>
<dubbo:reference xmlns=""
interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService" version="0.5.0"
id="ecAuthMenuI18n"></dubbo:reference>
在springboot的启动类中分别引入consumer和provider的xml配置。
现在我需要在consumer端加一个filter,于是,我在xml中增加了
<dubbo:consumer filter="UserConsumerFilter"/>
由于原来在application.properties中指定了
dubbo.consumer.check=false
启动报错:
2019-03-07 15:23:14.672 WARN 4116 --- [ main]
o.s.b.f.s.DefaultListableBeanFactory : Bean creation exception on non-lazy
FactoryBean type check:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception
is java.lang.IllegalStateException: Duplicate consumer configs:
<dubbo:consumer generic="false" filter="UserConsumerFilter"
id="com.alibaba.dubbo.config.ConsumerConfig" /> and <dubbo:consumer
generic="false" />
xml中的标签加了个id
<dubbo:consumer filter="UserConsumerFilter" id="aaa"/>
报错:
2019-03-07 16:56:32.498 WARN 6504 --- [ main]
o.s.b.f.s.DefaultListableBeanFactory : Bean creation exception on non-lazy
FactoryBean type check:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception
is java.lang.IllegalStateException: Duplicate consumer configs:
<dubbo:consumer generic="false" filter="UserConsumerFilter" id="aaa" /> and
<dubbo:consumer generic="false" />
我想这个是由于dubbo只能接受一个<dubbo:consumer />配置的原因吗?
这个是否能够作为一个issue提出来,后续加以改进呢?
谢谢。
您的朋友:刘志广