這篇部落格隻是我自己的學習記錄,對各位高手怕是沒有什麼太大的幫助,望高手不吝賜教。
項目的截圖如下:

我們使用的主要就是紅框裡面的。
這裡我主要分析兩個xml
/DubboTest/src/main/resources/spring/dubbo-provider.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"
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="hello-world-app" />
<!-- zookeeper注冊中心 -->
<dubbo:registry protocol="zookeeper" address="10.150.0.80:2181" />
<!-- 使用multicast廣播注冊中心暴露服務位址 -->
<!-- <dubbo:registry address="multicast://10.57.41.19:1234" /> -->
<dubbo:protocol name="dubbo" port="20880" />
<!-- 和本地bean一樣實作服務 -->
<dubbo:service interface="com.ruishenh.dubbo.example.DemoService" ref="demoService3" />
<bean id="demoService3" class="com.ruishenh.dubbo.example.DemoServiceImpl" />
</beans>
/DubboTest/src/main/resources/spring/dubbo-consumer.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"
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="consumer-of-helloworld-app" />
<!-- zookeeper注冊中心 -->
<dubbo:registry protocol="zookeeper" address="10.150.0.80:2181" />
<!-- 使用multicast廣播注冊中心暴露的服務位址 -->
<!--<dubbo:registry address="multicast://10.57.41.19:1234" /> -->
<!-- 生成遠端服務代理,可以和本地bean一樣使用demoService -->
<dubbo:reference id="demoService3" interface="com.ruishenh.dubbo.example.DemoService" />
</beans>
我就記錄一點
在consumer.xml裡面
<dubbo:reference id="demoService3" interface="com.ruishenh.dubbo.example.DemoService" />
這個id指的是
<bean id="demoService3" class="com.ruishenh.dubbo.example.DemoServiceImpl" />
這裡面這個id。
服務引用BeanId
我自己以前總覺得<dubbo:service裡面應該有個一個id,<dubbo:reference裡面應該有個一個屬性叫做fromid,指向dubbo:service那個id
另外
dubbo還有一個admin管理界面,請自行百度之。
項目代碼:
http://pan.baidu.com/s/1hqVbbQs