在写 dubbbo调用时候

<dubbo:reference  不能有空格!

项目结构:

pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.toov5</groupId>
<artifactId>toov5-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>toov5-order-dubbo-service</artifactId> <dependencies>
<dependency>
<groupId>com.toov5</groupId>
<artifactId>toov5-member-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency> <dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.5.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </project>

 业务:

package com.toov5.dubbo.consumer;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.toov5.api.member.service.MemberService;

public class OderToMemberTest {
public static void main(String[] args) { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("dubbo-consumer.xml");
MemberService memberService = applicationContext.getBean(MemberService.class);
String resultUser = memberService.getUser(12L);
System.out.println("调用服务后的返回结果"+resultUser);
}
}

dubbo配置

<?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-admin 或 dubbo-monitor 会显示这个名字,方便辨识 -->
<dubbo:application name="demotest-consumer" />
<!--使用 zookeeper 注册中心暴露服务,注意要先开启 zookeeper -->
<dubbo:registry address="zookeeper://192.168.91.5:2181" />
<!-- 用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name="dubbo" port="20880" />
<!--使用 dubbo 协议实现定义好的 MemberService 接口 -->
<dubbo:reference id="memberService" interface="com.toov5.api.member.service.MemberService"/>
</beans>

  启动:

只引入了接口 没有实现。 实现都是通过底层转换成rpc  dubbo协议进行调用的

 

最新文章

  1. 以项目谈WebGIS中Web制图的设计和实现
  2. 菜鸟学JS(五)——window.onload与$(document).ready()
  3. 一。常用UIView的属性和方法
  4. 实现JavaScript自定义函数的整合、链式调用及类的封装
  5. java读取properties配置文件的方法
  6. shell 实例收集
  7. fil_space_t
  8. Python中,如何初始化不同的变量类型为空值
  9. c++继承构造子类调用父类构造函数的问题及关于容器指针的问题及当容器里储存指针时,记得要手动释放
  10. C语言 &#183; 区间K大数查询
  11. children
  12. UVALive 2517 Moving Object Recognition(模拟)
  13. Spring详解(二)------IOC控制反转
  14. 好的Qt学习资料
  15. web安全之机器学习入门——2.机器学习概述
  16. 微信小程序:一起玩连线,一个算法来搞定
  17. Windows平台上谷歌浏览器损害电池
  18. (转)MySQL优化笔记(八)--锁机制超详细解析(锁分类、事务并发、引擎并发控制)
  19. Android JUnit 入门指南
  20. win10自带虚拟机安装CentOS7系统(转)

热门文章

  1. 性能测试脚本开发(LR.NET控件)
  2. HTTP学习笔记(一)报文和连接管理
  3. remove-duplicates-from-sorted-array-ii——去除重复
  4. 【LeetCode】Search in Rotated Sorted Array——旋转有序数列找目标值
  5. 26:IPMaskCheck识别有效的ip地址和掩码并分类统计
  6. Struts2实现input数据回显
  7. JavaScript之this的工作原理
  8. ABAP 弹出框 函数
  9. Git --更改远程分支名
  10. C# C/S程序使用HTML文件作为打印模板