dubbo 部分 配置的關系-dubbo github 官方案例
1、dubbo 有一個 dubbo.properties 作為默認配置
默認配置可以在不添加新的配置的前提下使用dubbo
dubbo.properties 的內容(來自 https://github.com/alibaba/dubbo)
2、dubbo 學習參考鏈接
·dubbo-admin管理控制臺的安裝和使用:http://www.cnblogs.com/aqsunkai/p/6690607.html
·dubbo官網,下載和配置說明:http://dubbo.io/
·dubbo結合Spring:http://blog.csdn.net/congcong68/article/details/41113239
·dubbo 配置 :http://www.cnblogs.com/linjiqin/p/5859153.html
·zookeeper 基本含義: http://blog.csdn.net/gyflyx/article/details/18652913
3、本地環境搭建-zookeeper(windows 環境)
http://blog.csdn.net/bestcxx/article/details/73440892
4、從github下載 dubbo 測試所需的幾個工程
https://github.com/alibaba/dubbo
先全部下載,然後取其中的 dubbo-admin和dubbo-demo
dubbo-admin是dubbo監控平臺,可以打包為war或者直接jetty運行(maven 配置 jetty 插件),啟動後訪問 http://localhost:9999/dubbo-admin 端口9999看你怎麽定義了
需要輸入用戶名和密碼:root/root
之後點擊 返回首頁
然後進入預期的界面了
dubbo-demo聚合了demo-api\demo-consumer\demo-provider
demo-api是接口,demo-proveider 實現了demo-api
demo-provider是提供者
demo-consumer是消費者
demo-provider和demo-consumer 都是在test中提供main方法啟動,demo-consumer 一直調用,可以看到兩個平臺的交互
5、實驗得出的結論
dubbo.properties 會起到默認配置的作用
但是 dubbo-demo-provider.xml 中的配置可以對dubbo.properties 的配置進行覆蓋和擴展(這意味著某些配置不是必須的)
dubbo-demo-provider.xml 的內容(DemoTwoServiceImpl.java 和 DemoTwoService.java 是新增的兩個類,分別加在dubbo-provider 和 dubbo-api中,參照先例即可)
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- - Copyright 1999-2011 Alibaba Group.
- -
- - Licensed under the Apache License, Version 2.0 (the "License");
- - you may not use this file except in compliance with the License.
- - You may obtain a copy of the License at
- -
- - http://www.apache.org/licenses/LICENSE-2.0
- -
- - Unless required by applicable law or agreed to in writing, software
- - distributed under the License is distributed on an "AS IS" BASIS,
- - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- - See the License for the specific language governing permissions and
- - limitations under the License.
- -->
- <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-2.5.xsd
- http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
- <!-- bean的聲明和Spring無差異 -->
- <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl" />
- <bean id="demoTwoService" class="com.alibaba.dubbo.demo.provider.DemoTwoServiceImpl" />
- <!-- 由於dubbo.propertirs 的存在,可以直接配置 <dubbo:service>對外暴露服務,即存在默認的配置, -->
- <dubbo:service interface="com.alibaba.dubbo.demo.DemoTwoService" ref="demoTwoService" group="dubbodemoregister2"/>
- <!-- 如果需要使用個性化配置,則需要單獨配置,比如服務提供者協議配置、註冊中心配置 、服務提供者缺省值配置-->
- <!-- 服務提供者協議配置-dubbo會覆蓋dubbo.properties: -->
- <!-- <dubbo:protocol id="dubbodemo" name="dubbo" port="20882"/> -->
- <!-- 註冊中心配置-會覆蓋 dubbo.proerties,這個本質就是 dubbo:service的group: -->
- <dubbo:registry id="dubbodemoregister" address="zookeeper://127.0.0.1:2181" protocol="dubbo"/>
- <dubbo:registry id="dubbodemoregister2" address="zookeeper://127.0.0.1:2181" protocol="dubbo"/>
- <!-- 服務提供者缺省值配置-所有服務提供者自動擁有此配置-這意味著,這個配置一個就夠了: -->
- <!-- <dubbo:provider id="dubbodemoprovider" group="dubbodemoregister" timeout="30000" retries="0"/> -->
- <!-- 服務提供者暴露服務配置: -->
- <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService" group="dubbodemoregister"/>
- </beans>
dubbo 部分 配置的關系-dubbo github 官方案例