dubbo中關於protocol的配置

dubbo中關於protocol的配置

protocol 一個項目中可以配置多個,如果未定義port默認爲20880(本人因爲從網上copy了一個
<dubbo:protocol accesslog="true"/>,而且已定義<dubbo:protocol name="dubbo" port="20880" />,當我啓動項目的多個實例時只修改了定義端口的protocol,而默認的未被修改,其他dubbo服務就會報端口已被佔用程序退出的異常)

錯誤代碼片段:
<?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:application name="demo-provider" />
<dubbo:registry address="zookeeper://localhost:2181"/>
<!-- 用dubbo協議在20880端口暴露服務 -->
<dubbo:protocol name="dubbo" port="20880" />
<dubbo:protocol accesslog="true" />
<dubbo:service interface="com.ssyt.dubbo.demo.DemoService" ref="demoService"/>
<bean id="demoService" class="com.ssyt.dubbo.dome.provider.DemoServiceImpl"/>
</beans>

紅色部分爲衝突代碼,可改爲不同的端口,一個項目中一種協議最好只定義一次
修改後的代碼爲:
<?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:application name="demo-provider" />
<dubbo:registry address="zookeeper://localhost:2181"/>
<!-- 用dubbo協議在20880端口暴露服務 -->
<dubbo:protocol name="dubbo" port="20880" accesslog="true"/>
<dubbo:service interface="com.ssyt.dubbo.demo.DemoService" ref="demoService"/>
<bean id="demoService" class="com.ssyt.dubbo.dome.provider.DemoServiceImpl"/>
</beans>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章