Spring Cloud feign使用okhttp3
2024-10-08 08:07:35
指南
maven
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
配置文件
feign.httpclient.enabled=false
feign.okhttp.enabled=true
配置
@Configuration
@ConditionalOnClass(Feign.class)
@AutoConfigureBefore(FeignAutoConfiguration.class)
public class FeignOkHttpConfig {
@Autowired
OkHttpLoggingInterceptor okHttpLoggingInterceptor;
@Bean
public okhttp3.OkHttpClient okHttpClient(){
return new okhttp3.OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.writeTimeout(120, TimeUnit.SECONDS)
.connectionPool(new ConnectionPool())
// .addInterceptor();
.build();
}
}
实践
不需要额外编写FeignOkHttpConfig,feign本身已经存在FeignOkHttpAutoConfiguration了,不需要额外配置。
最新文章
- Silverlight动态生成控件实例
- TCP/IP 端口号大全
- 11.Android之常用对话框AlertDialog学习
- MySQL中varchar类型在5.0.3后的变化
- 在 OS X Yosemite 中部署Mesos
- html移动端开发注意事项
- (转)20 个大大节省你时间的 HTML5 开发工具
- Bower+grunt-wiredep自动注入包到html
- TCP TIME WAIT
- 运维面试题之linux基础
- org.hibernate.AssertionFailure: null id in xxx entry (don&#39;t flush the Session after an exception occurs)
- JavaScript实现input输入框限制输入值的功能
- PHP中get请求中参数的key不能是para
- ElasticSearch集群介绍二
- C++中类的前向声明
- Django本地开发,引用静态文件,火狐浏览器不能访问静态文件,谷歌浏览器却能访问静态文件
- python selenium爬取QQ空间方法
- mtime参数的理解
- Qt计算器开发(三):执行效果及项目总结
- 基于Linux的Samba开源共享解决方案测试(三)
热门文章
- Codeforces 1092 F Tree with Maximum Cost (换根 + dfs)
- 搭建python运行环境
- Kafka系列3:深入理解Kafka消费者
- 事务特性ACID及隔离级别
- JMeter之If Controller深究二
- Python趣味入门02: 妥妥地安装配置Python(Windows版)
- Kali桥接模式下配置ip
- Visual C# 2015调用SnmpSharpNet库实现简单的SNMP元素查询
- 大数四则运算之减法运算-----c语言版
- #614 C. NEKO&#39;s Maze Game[简易DFS,0|1转换]