OpenFeign
程序员文章站
2024-02-14 12:34:04
...
简单记录一下open Feign的用法
1.添加依赖,
2.在启动类上添加注解:@EnableFeignClients
3.创建服务类----用于调用远程服务
@Component
@FeignClient("PAYMENT") //要调用的服务名
public interface PaymentFeignService {
//远程服务的handler
@RequestMapping("payment/query")
@ResponseBody
CommonResult<Payment> query(@RequestBody Long id);
@RequestMapping("test")
@ResponseBody
void test();
}
4.业务类中调用
@Resource
PaymentFeignService paymentFeignService;
@RequestMapping("/test")
@ResponseBody
public CommonResult<Payment> test(){
System.out.println("feign here ");
paymentFeignService.test();
return null;
}
超时控制
ribbon:
ReadTimeout = 5000
ConnectTimeout = 5000
日志增强
@Bean
Logger.Level feignLoggerLevel(){
return Logger.Level.FULL;
}
设置监听接口的级别
logging:
level:
org.yuanqi.customerfeign83.service.PaymentFeignService: debug
上一篇: 放大缩小VML
推荐阅读
-
OpenFeign
-
聊聊openfeign的超时和重试
-
spring boot openfeign从此和httpClient说再见详析
-
springboot openfeign从JSON文件读取数据问题
-
spring boot openfeign从此和httpClient说再见详析
-
springboot openfeign从JSON文件读取数据问题
-
Nacos(三):Nacos与OpenFeign的对接使用
-
SpringCloud(七)---OpenFeign访问带有参数的控制器
-
springboot~openfeign从JSON文件读取数据
-
4-CloudAlibaba-Sentinel(整合OpenFeign)学习笔记2020.10.24