当前位置:网站首页>openFeign 服务调用
openFeign 服务调用
2022-04-22 06:34:00 【Leon_Jinhai_Sun】
# 1.服务调用方法引入依赖OpenFeign依赖
<!--Open Feign依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
# 2.入口类加入注解开启OpenFeign支持
@SpringBootApplication
@EnableFeignClients
public class Users9999Application {
public static void main(String[] args) {
SpringApplication.run(Users9999Application.class, args);
}
}
# 3.创建一个客户端调用接口
//value属性用来指定:调用服务名称
@FeignClient("PRODUCTS")
public interface ProductClient {
@GetMapping("/product/findAll") //书写服务调用路径
String findAll();
}
# 4.使用feignClient客户端对象调用服务
//注入客户端对象
@Autowired
private ProductClient productClient;
@GetMapping("/user/findAllFeignClient")
public String findAllFeignClient(){
log.info("通过使用OpenFeign组件调用商品服务...");
String msg = productClient.findAll();
return msg;
}
# 5.访问并测试服务
- http://localhost:9999/user/findAllFeignClient
版权声明
本文为[Leon_Jinhai_Sun]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Leon_Jinhai_Sun/article/details/124232077
边栏推荐
- Import 3D model from web page - obj / MTL file
- Leaders of Hangzhou commercial password Application Association and their delegation visited Shiping for information exchange
- utgard连接opcserver报错Caused by: org.jinterop.dcom.common.JIRuntimeException: Access is denied. [0x800
- Monkey actual combat
- systemctl启动prometheus+grafana环境
- laravel 新建路由文件
- Monkey introduction operation
- 通用测试技术【二】测试方法
- Shrio 学习笔记(二)
- 为什么我那么看重文档命名?
猜你喜欢

monkey

JMeter simulates get requests

postman接口自动化-4-Tests断言4:自定义接口执行顺序

.net WebAPI访问授权机制及流程设计(header token+redis)
Web automation: 5.2 selenium mouse operation principle: actionchains delay call

Web课设----HIS系统

Bert model series 1: what exactly is input?

Web automation: 5.1 selenium mouse operation - click, double click, right click, hover, drag

Under the window environment, VirtualBox loads the virtual machine created in the mobile hard disk

How to connect Kunlun on state │ G series screen with Siemens 300 domestic MPI adapter
随机推荐
Monkey introduction operation
华为手机adb devices连接设备为空
laravel 新建路由文件
Seven steps of PLC project commissioning
JMeter performance indicator monitoring: CPU, memory, disk, network
实验5 组件及事件处理
Software development specification
jmeter 模拟 get 请求
.net core CefSharp ChromiumWebBrowser中网站JS调用winfrom程序中C#方法
LDAP用户登录认证校验及查询
easyui的combobox实现三级查询
Web problem location practice: 2 Prompt information and field verification
通用测试技术【一】测试的分类
判断所给年份中是否有闰年
postman接口自动化-3-Tests断言3:获取动态参数,设置环境变量(接口关联)
Training and empowerment | building a professional technical service team
MYSQL05_ORDR BY排序、LIMIT分组、GROUP BY分组
Under the window environment, VirtualBox loads the virtual machine created in the mobile hard disk
Web automation: how to realize browser window scrolling in 8.3 selenium
学生成绩管理