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>