1. 程式人生 > >dubbo應用既當提供者又當消費者java.lang.IllegalStateException: Duplicate application configs

dubbo應用既當提供者又當消費者java.lang.IllegalStateException: Duplicate application configs

AR def 原因 art ati tee nco tail name

一個dubbo的應用啟動時報錯:java.lang.IllegalStateException: Duplicate application configs。原因如下:

當一個應用既當提供者和消費者時,必定會分別配置應用的名稱:

提供者:

[html]
  1. <dubbo:application name="XXXX" />


消費者:

[html]
  1. <bean id="dubbo_application" class="com.alibaba.dubbo.config.ApplicationConfig">
  2. <property name="name" value="XXX"/>
  3. </bean>


這時啟動應用時就會抱錯:

java.lang.IllegalStateException: Duplicate application configs: <dubbo:application name="XXX" id="XXX" /> and <dubbo:application name="XXXX" id="XXXX" />

解決方法是:

[html]
    1. <bean id="dubbo_application" default="false" class="com.alibaba.dubbo.config.ApplicationConfig">
    2. <property name="name" value="XXX"/>
    3. </bean>

dubbo應用既當提供者又當消費者java.lang.IllegalStateException: Duplicate application configs