当前位置:网站首页>每天20分钟之feign
每天20分钟之feign
2022-07-24 15:32:00 【李子健】
feign提供的功能
java支持的接口调用方式
- httpclient
- okhttp
- httpURLConnection
- RestTemplate
feign对各类http调用包进行了抽象,我们不必自己去调用http包,feign进行了封装
feign的使用
spring.application.name=eureka-client-front
server.port=7012
eureka.client.serviceUrl.defaultZone=http://tom:[email protected]:6010/eureka/,http://tom:[email protected]:6020/eureka/
eureka.instance.preferIpAddress=true
eureka.instance.instance-id=${spring.application.name}:${spring.cloud.client.ip-address}:${server.port}
eureka.client.healthcheck.enabled=true
eureka.instance.lease-expiration-duration-in-seconds=5
eureka.instance.lease-renewal-interval-in-seconds=15
eureka.instance.metadata-map.yuantiandi=tom
ribbon.eureka.enabled=true
logging.level.com.cxytiandi.feign_demo.remote.UserRemoteClient=DEBUG
feign.httpclient.enabled=false
feign.okhttp.enabled=true
feign.client.config.eureka-client-user.connect-timeout=1000
feign.client.config.eureka-client-user.readTimeout=1000
@FeignClient(value="eureka-client-user", configuration= FeignConfiguration.class)
public interface UserInfoClientApi {
@GetMapping("/user/{uid}")
public String info(@PathVariable long uid);
}
@Slf4j
public class FeignAuthInterceptor implements RequestInterceptor {
public FeignAuthInterceptor() {
}
@Override
public void apply(RequestTemplate template) {
log.info("拦截器生效了");
}
}
@Configuration
public class FeignConfiguration {
/**
* 日志级别
*
* @return
*/
@Bean
Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor("tom", "123456");
}
@Bean
public FeignAuthInterceptor feignBasicAuthRequestInterceptor() {
return new FeignAuthInterceptor();
}
}附录
边栏推荐
- 新手第一次怎么买股票 哪家证券公司开户最好最安全
- PyTorch的自动求导
- sklearn.metrics模块模型评价函数
- [quantitative test]
- Performance test - Test Execution
- C # exit login if there is no operation
- MySQL学习笔记(总结)
- Memorythrashing: Tiktok live broadcast to solve memory dithering practice
- 《Route planning method for UAV in unknown environment based on improved SAS algorithm》翻译
- 【洛谷】P1908 逆序对
猜你喜欢

Kubectl_ Easy to use command line tool: Oh my Zsh_ Tips and tricks

Intelligent operation and maintenance scenario analysis: how to detect abnormal business system status through exception detection

报错【项目报错】

2022 RoboCom 世界机器人开发者大赛-本科组(省赛)---第一题 不要浪费金币 (已完结)

JMeter - call the interface for uploading files or pictures

【量化测试】

Choice of advanced anti DDoS IP and CDN in case of DDoS

Leetcode-09 (next rank + happy number + full rank)

【AdaptiveAvgPool3d】pytorch教程

Route planning method for UAV in unknown environment based on improved SAS algorithm
随机推荐
Analysis of some difficulties in VAE (variational self encoder)
zabbix管理员忘记登录密码
【洛谷】P1908 逆序对
Problems needing attention in mobile terminal testing
Leetcode-09 (next rank + happy number + full rank)
2022 robocom world robot developer competition - undergraduate group (provincial competition) rc-u4 strategy team (completed)
25.从生磁盘到文件
【TA-霜狼_may-《百人计划》】图形3.4 延迟渲染管线介绍
[quantitative test]
Huffman tree (optimal binary tree)
接参处理和@Param
Leetcode 1288. delete the covered interval (yes, solved)
You can't just focus on flex layout and elaborate animation to explain all flex layout methods! Easy to understand dry goods tutorial
哈夫曼树(最优二叉树)
遭受DDoS时,高防IP和高防CDN的选择
Personal practical experience: Data Modeling "whether account data belongs to dimension or account domain"
26.文件使用磁盘的代码实现
AG. DS binary tree -- hierarchical traversal
力扣 31.下一个排列--双指针法
Preparation of mobile end test cases