当前位置:网站首页>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
边栏推荐
- Getting started with detectron2
- Hystrix组件
- 清华大学 | WebFace260M:百万级深度人脸识别的基准(TPAMI2022)
- ERP function_ Financial management_ Basic concepts of Finance
- Pycharm Chinese plug-in
- [leetcode refers to the two numbers of offer 57. And S (simple)]
- Reference of custom message in ROS function pack failed
- ROS learning notes - tutorial on the use of ROS
- Oracle updates the data of different table structures and fields to another table, and then inserts it into the new table
猜你喜欢

Introduction to tensorrt

C, print the source program of beautiful bell triangle

Thinkphp5 + data large screen display effect

MVC three-tier architecture (illustration)

在线时序流程图制作工具

在线Excel转CSV工具

Tsinghua University | webface260m: benchmark for million level deep face recognition (tpami2022)

Lightweight project management ideas

IIS cannot load * woff,*. woff2,*. Solution of SVG file

Database Experiment four View experiment
随机推荐
2022 - 04 - 24 Daily: Current Progress and Open Challenges of Applied Deep Learning in Biological Sciences
Pytorch: runtimeerror: an attempt has been made to start a new process Error reporting (resolved)
MVC three-tier architecture (illustration)
Unit function expansion
LabVIEW修改应用程序窗口外观
Swift import third-party library reports an error no such module““
服务熔断的实现
Devops and cloud computing
A method of asynchronous response of application service through load balancing
Echerts add pie chart random color
上海确保疫情保供生活物资质量和食品安全
Leaf Smecta
[leetcode refers to offer 47. Maximum value of gift (medium)]
Online Excel to CSV tool
How Axure installs a catalog
服务雪崩、服务熔断、服务降级
Tencent cloud has two sides in an hour, which is almost as terrible as one side..
2.整理华子面经--2
openfeign集成Hystrix的备选方案处理
服务降级的实现