当前位置:网站首页>openFeign 服务调用
openFeign 服务调用
2022-04-23 21:58: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
边栏推荐
- 管道和xargs
- Tencent cloud has two sides in an hour, which is almost as terrible as one side..
- C language programming based on loop structure (PTA)
- 2. Finishing huazi Mianjing -- 2
- Ensuring the quality of living materials and food safety in Shanghai
- Devops and cloud computing
- Online timing flow chart making tool
- How Axure installs a catalog
- airbase 初步分析
- [※ leetcode refers to offer 46. Translate numbers into strings (medium)]
猜你喜欢
Sqlserver edits data in the query interface (similar to Oracle's edit and ROWID)
openfeign集成Hystrix的备选方案处理
Thinkphp5 + data large screen display effect
[leetcode sword finger offer 58 - I. flip word order (simple)]
hystrix dashboard的使用
[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]
C reads excel specific data into specific columns of DataGridView
JUnit unit test ---- a good tool for testing a single method
C, print the source program of beautiful bell triangle
Deep understanding of modern mobile GPU (continuously updating)
随机推荐
Pyuninstaller package exe cannot find the source code when running, function error oserror: could not get source code
JUnit unit test ---- a good tool for testing a single method
This paper solves the cross domain problem of browser
IIS cannot load * woff,*. woff2,*. Solution of SVG file
C list data paging
When pycharm debugs, view the tensor image of pytorch in the console
Unit function expansion
A solution of C batch query
Database experiment I database definition and data import
Tsinghua University | webface260m: benchmark for million level deep face recognition (tpami2022)
Lightweight project management ideas
Hystrix简介和服务端熔断的实现
Is rust more suitable for less experienced programmers?
Subcontracting of wechat applet based on uni app
2.整理华子面经--2
South Korea may ban apple and Google from offering commission to developers, the first in the world
Mixed use of Oracle column row conversion and comma truncated string
MySQL 回表
Database Experiment 3 data update experiment
2022-04-24日報:在生物科學領域應用深度學習的當前進展和開放挑戰