Dubbo的@Reference和@Service说明---1Reference用在消费者2Service用在提供者【import com.alibaba.dubbo.config.annotation.Service;】
@Reference 用在消费端,表明使用的是服务端的什么服务@RestController
public class RemoteUserController {
@Reference(version = "1.0.0",check = true)
private RemoteUserService remoteUserService;
@RequestMapping(value="/dubbo/say/{name}")
public String sayHello(@PathVariable("name") String name){
//调用服务提供者的服务
String result=remoteUserService.sayHello(name);
return result;
}
}
@Service 用在服务提供者中,在类或者接口中声明。
服务提供者实现相关的服务接口,当消费端调用相关的类时,最终会调用提供者的实现方法。
@Component
@Service(version = "1.0.0",timeout = 10000,interfaceClass = RemoteUserService.class)
public class RemoteUserServiceImpl implements RemoteUserService { @Override
public String sayHello(String name) { log.info("访问sayHello " + name);
return "Hello " + name;
}
}
Dubbo的@Reference和@Service说明---1Reference用在消费者2Service用在提供者【import com.alibaba.dubbo.config.annotation.Service;】的更多相关文章
- org.springframework.stereotype.Service和com.alibaba.dubbo.config.annotation.Service两种service的区别
这两个Service,都可以在service类头上使用@Service的注解,于是我就写错了,查了半天才发现.他们的区别大概是这个样子的: org.springframework.stereotype ...
- dubbo在idea下的使用创建 服务者,消费者 注册中心
1.基于windows 下 spring 下的dubbo 需要书写配置文件 (1).创建带有web工程的项目 创建一个服务者 package cn.edu.aynu.bean; import lo ...
- dubbo No provider available for the service com.alibaba.dubbo.monitor.MonitorService from registry
No provider available for the service com.alibaba.dubbo.monitor.MonitorService from registry http:// ...
- com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method findUserByUserNo in the service wusc.edu.facade.user.service.PmsUserFacade.
017-04-25 10:55:30,505 INFO [AbstractRegistry.java:302] : [DUBBO] Register: consumer://192.168.1.101 ...
- com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote method解决方法
报错日记: Caused by: com.alibaba.dubbo.rpc.RpcException: Failed to invoke remote method: getUserAuthLeve ...
- dubbo的消费者是怎么获取提供者服务接口引用的?
本文主要解读dubbo消费者是如何引用服务端接口的,是如何像本地调用一样调用远程服务的. 并试着从设计者的角度思考,为何这样设计. @Component public class DubboConsu ...
- com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: dubbo://192.16。。
开启了linux的zookeeper服务,启动e3-manager时发现出现com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: ...
- com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method
查看了网友们的错误原因, 需要进行实例化的类没有进行实例化,具体没有实例化的类会在错误信息中显示,在错误信息中搜索“Serializable”即可找到将其实现序列化可消除错误. 是在使用Dubbo提供 ...
- [TODO]com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method
异常信息如下: 2018-10-30 20:00:50.230 ERROR java.util.concurrent.ExecutionException: com.alibaba.dubbo.rpc ...
随机推荐
- C++ 中 字符数组 和 指针 区别
char str1[] = "abc"; char str2[] = "abc"; const char str3[] = "abc"; c ...
- HDU - 2159 FATE(二维dp之01背包问题)
题目: 思路: 二维dp,完全背包,状态转移方程dp[i][z] = max(dp[i][z], dp[i-1][z-a[j]]+b[j]),dp[i][z]表示在杀i个怪,消耗z个容忍度的情况下 ...
- Nodejs介绍及其安装
一.Nodejs介绍 Nodejs英文网:https://nodejs.org/en/ Nodejs中文网:http://nodejs.cn/ Node.js 是一个基于 Chrome V8 引擎的 ...
- Problem 21
Problem 21 https://projecteuler.net/problem=21 Let d(n) be defined as the sum of proper divisors of ...
- 【3】数据筛选2 - requests
目录 1.概述 2.下载安装 3.入门程序 4.请求对象:请求方式 5.请求对象:GET参数传递 6.请求对象:POST参数传递 7.请求对象: ...
- Tomcat 7源码学习笔记 -9 tomcat重启后session仍然保留
使用Tomcat 7缺省的配置,tomcat关闭后重新启动,发现原来的session没有被删掉,用原来的request获取session仍然可以取到.但是并没有配置session持久化. 原因如下: ...
- 51nod——T1267 4个数和为0
https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1267 题目描述 给出N个整数,你来判断一下是否能够选出4个数,他们的和 ...
- Spring MVC-表单(Form)标签-下拉框(Dropdown)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_dropdown.htm 说明:示例基于Spring MVC 4.1.6. 以下示 ...
- HDU 3167 KMP
很久之前做的一题,忽然想起来,依然觉得思路巧妙. //这道题,确实是一道好题.但如何应用KMP,确实大大超出了意料中. //这道题匹配的是某元素在子串中的名次,也就是在子串中排第几小.我想了整整一天, ...
- Oracle推断值为非数字
select * from product_info t where t.contract_detailid is not null and length(translate(t.contract_d ...