当前位置:网站首页>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
边栏推荐
- Detectron2 usage model
- When pycharm debugs, view the tensor image of pytorch in the console
- C reads excel specific data into specific columns of DataGridView
- Idea import a project
- Question brushing plan - depth first search (II)
- 在线时序流程图制作工具
- Pipes and xargs
- April 24, 2022 Daily: current progress and open challenges of applying deep learning in the field of Bioscience
- How to play the guiding role of testing strategy
- Problem brushing plan -- dynamic programming (IV)
猜你喜欢
![[leetcode refers to offer 10 - I. Fibonacci sequence (simple)]](/img/f9/22a379f330c3ee21a2a386bbd4a98f.png)
[leetcode refers to offer 10 - I. Fibonacci sequence (simple)]

Google tries to use rust in Chrome

Problem brushing plan -- dynamic programming (IV)

Is rust more suitable for less experienced programmers?

opencv应用——以图拼图

Resolve the "chromedriver executable needs to be in path" error
![[leetcode sword finger offer 28. Symmetric binary tree (simple)]](/img/bc/1f0c9e70470c7d60f821a4ecc2271f.png)
[leetcode sword finger offer 28. Symmetric binary tree (simple)]

Database Experiment 8 trigger experiment

Mixed use of Oracle column row conversion and comma truncated string

Tear the Google SRE book by hand
随机推荐
Pytorch deep learning practice (2)
Oracle intercepts special characters
Database Experiment 7 stored procedure experiment
Pycharm Chinese plug-in
使用mbean 自动执行heap dump
1.整理华子面经--1
Hystrix组件
2.整理华子面经--2
Hystrix断路器开启条件和流程以及默认备选处理
C language programming based on loop structure (PTA)
C reads excel specific data into specific columns of DataGridView
airbase 初步分析
Crisis is opportunity. Why will the efficiency of telecommuting improve?
[leetcode refers to offer 27. Image of binary tree (simple)]
Hystrix简介和服务端熔断的实现
Flomo software recommendation
[leetcode refers to the substructure of offer 26. Tree (medium)]
Database experiment VI integrity language experiment
Based on jsplumb JS to achieve multi list one to many connection effect
YOLOv5 Unable to find a valid cuDNN algorithm to run convolution