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 ...
随机推荐
- Django - app
1.app目录 migrations:数据库操作的记录(只记录修改表结构的记录); __init__文件:python2中必须填加,python3中无要求,可以不添加: admin:django为我们 ...
- SqlServer 【基 本 操 作】
1.Row_Number() select * from (select Row_Number() over (order by FSalary) as 'RowNum' ,* from dbo.T_ ...
- 7-9 旅游规划 (25 分)(Dijkstra算法)
题意: 思路:单源最短路问题,Dijkstra算法搞定就可以了,因为要找出最便宜的最短路,所以需要在更新最短距离的时候加一个条件(即当最短距离相等的时候,如果该路径的花费更小,就更新最小花费)就可 ...
- NOIP2018 滚粗记
Day -2 上午,大家都在复习各种模板,zhx总结了足足67个模板(杨辉三角也算模板???),lgl死磕FFT发现cos和sin打反了,我也是复习板子和以前做过的题,几乎没有人颓. 接着jdr,l ...
- 让TP5.0在SWOOLE上飞起来
TP-SWOOLE 目前,TP5.1官方已经提供了think-swoole2.0,集成程度以前优雅很多,不过5.0的集成方式确实有些鸡肋.所以看了下2.0,为5.0开发了一个扩展包,可以采用compo ...
- 强悍的 ubuntu —— 命令行访问网页
所谓以命令行的方式访问网页,即是在终端下以文本的形式访问网站,这里推荐一个工具:w3m, $ sudo apt-get install w3m $ w3m www.baidu.com
- Linux学习总结(3)——Linux实用工具
1. Windows下同步Linux文件(Linux安装Samba和配置) 场景需求: 安装了Ubuntu在虚拟机上,但是代码编辑或者其它更多的操作的时候,还是习惯在windows下进行.如果wind ...
- [ZJOI2010]Perm
[ZJOI2010]Perm 题目 称一个1,2,...,N的排列P1,P2...,Pn是Magic的,当且仅当2<=i<=N时,Pi>Pi/2. 计算1,2,...N的排列中有多少 ...
- nyoj 306 二分+dfs
#include<stdio.h> #include<string.h> #define N 200 int Min(int a,int b) { return a>b? ...
- 关于在JSP页面中为什么一定要用${pageContext.request.contextPath}来获取项目路径,而不能用${request.contextPath}?
这里的疑问在于pageContext和request都是JSP中的内置对象之一,为什么不直接用${request.contextPath}来获取项目路径? 出现这种疑问,其实是将JSP的内置对象和EL ...