zoukankan      html  css  js  c++  java
  • Dubbo 的 Helloworld

    •  前提条件

    安装好了 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>
  • 相关阅读:
    让DateTimePicker显示空时间值 (转) 武胜
    Webcam in C#: AForge.NET (转) 武胜
    C#自定义事件的步骤 武胜
    交换机VLAN的配置 (转) 武胜
    虚拟LAN安全的最佳实践经验 (转) 武胜
    绿色版 MySQL 的安装配置 (转) 武胜
    net 中捕获摄像头视频的方式及对比(How to Capture Camera Video via .Net) (转) 武胜
    C# WndProc的使用方法 (转) 武胜
    金融证券业Windows NT服务器热备份系统工作示意图 (转) 武胜
    ubuntu下配置samba实现文件夹共享
  • 原文地址:https://www.cnblogs.com/sherrykid/p/5851517.html
Copyright © 2011-2022 走看看