• 前提条件

安装好了 ZooKeeper 作为注册中心

  • 服务端
<?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:context="http://www.springframework.org/schema/context"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!--这个包下的,所有加过特殊注解的类,都被Spring管理-->
<context:component-scan base-package="org.zln" resource-pattern="**/*ServiceImpl.class"/> <!--开启注解注入-->
<context:annotation-config/> <dubbo:application name="providerDemo" />
<!--ZooKeeper 注册中心-->
<dubbo:registry protocol="zookeeper" address="127.0.0.1:2181" />
<!--Dubbo 协议暴露服务的端口-->
<dubbo:protocol name="dubbo" port="20880" />
<!--需要暴露的服务接口-->
<dubbo:service interface="org.zln.service.SayHelloService" ref="sayHelloService"/> </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:context="http://www.springframework.org/schema/context"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!--dubbo 消费方名称-->
<dubbo:application name="consumerDemo" /> <!--ZooKeeper 注册中心-->
<dubbo:registry address="zookeeper://127.0.0.1:2181" />
<!--生成远程服务代理-->
<dubbo:reference id="sayHelloService" interface="org.zln.service.SayHelloService"/>
</beans>

Dubbo 的 Helloworld的更多相关文章

  1. Dubbo 版 Helloworld

    使用工具:MAVEN.IDEA.Spring.Dubbo.Zookeeper 直接上代码 项目结构: 步骤如下: 搭建MAVEN项目,添加相关依赖 pom.xml <!--Zookeeper-- ...

  2. Dubbo(五) Dubbo入门demo——helloworld

    前言 前面我已经介绍了dubbo的一些基本工具和知识,让大家简单的了解了下RPC框架和Dubbo.接下来就是重点了,Dubbo的helloworld项目. 一.搭建项目 首先我们新建三个maven项目 ...

  3. Dubbo与SpringBoot整合流程(从实例入手,附代码下载)

    场景 Dubbo环境搭建-管理控制台dubbo-admin实现服务监控: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10362 ...

  4. Dubbo--002--例子程序

    虽然项目中用到了dubbo,还是想自己玩玩写个demo.百度一搜,关于dubbo的helloworld基本都是在windows上做的.现在在Linux上玩一下. 环境准备: jdk版本:1.7 服务器 ...

  5. Dubbox 环境搭建

    第一章:Dubbox简介 Dubbox是一个开源的RPC(Remote ProcedureCall Protocol)远程调用框架,是由dangdang对阿里的Dubbo的升级,可以被视为Dubbo的 ...

  6. JMicro微服务Hello World

    概述 JMicro是本人开发的基于Java实现的微服务框架,前两天发布0.0.3正式版本,并已发布到maven中央仓库. 项目源码github:https://github.com/mynewworl ...

  7. Dubbo源码-从HelloWorld开始

    Dubbo简介 Dubbo,相信做后端的同学应该都用过,或者有所耳闻.没错,我就是那个有所耳闻中的一员. 公司在好几年前实现了一套自己的RPC框架,所以也就没有机会使用市面上琳琅满目的RPC框架产品. ...

  8. dubbo入门之helloWorld

    dubbo官方文档:http://dubbo.apache.org/zh-cn/docs/user/quick-start.html 基于spring coloud的demo:http://start ...

  9. Dubbo学习笔记(一) 基础知识HelloWorld

    Dubbo是由阿里巴巴研发出的一款基于Java实现的RPC框架,现由Apache进行维护管理,笔记中使用zookeeper作为注册中心,dubbo+zookeeper环境安装教程:https://ww ...

随机推荐

  1. MyEclipse格式化JSP代码导致Java表达式<%= %>自动换行的解决办法

    MyEclipse格式化JSP代码导致Java表达式<%= %>自动换行的解决办法: 可以将Java表达式<%= %>换成EL表达式.

  2. json_decode结果为null的几种原因

    值只能是UTF-8编码,元素最后不能有逗号,元素不能使用单引号,元素值中间不能有空格和n.

  3. hadoop生态搭建(3节点)-01.基础配置

    # 基础配置# ==================================================================node1 vi /etc/hostname nod ...

  4. python查询mysql数据

    >>>cur.execute("select * from 表名") >>>lines=cur.fetchall() >>>f ...

  5. go学习笔记-变量和常量

    变量和常量 变量 基本写法 //定义一个名称为"variableName",类型为"type"的变量 var variableName type //定义三个类 ...

  6. WRITE

    WRITE - int_format_options   基本形式    ... [LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED]     [NO-GAP]      ...

  7. cmd中可以运行java,但不能运行javac命令

    在cmd中可以运行java,但运行javac命令时提示:'javac' 不是内部或外部命令,也不是可运行的程序或批处理文件. 原因:安装java时把jdk的路径和jre的路径选择成一样,就造成覆盖了. ...

  8. n个台阶,每次都可以走一步,走两步,走三步,走到顶部一共有多少种可能

    分析 第一个台阶  1第二个台阶  11 2    //走两次1步或者走1次两步第三个台阶  111 12 21 3 第四个台阶  1111 112 121 211 22 13 31 思想:4阶台阶, ...

  9. Java检测端口的占用情况

    突然间想到这个问题,在网上搜了一下 http://blog.csdn.net/danieluk/article/details/18518175 网上有很多文章都是用上面那个方法来解决这个问题的,总感 ...

  10. Prolog奇怪奇妙的思考方式

    今天在<七周七语言>中接触到了prolog,发现它的编程模式和思考方式的确比较奇怪,但同时也非常奇妙,值得学习一下. 1. prolog语言介绍     和SQL一样,Prolog基于数据 ...