HttpUtil请求如何设置全局超时时间
retrofit2 + okhttp3
比这个好用太多了!!!!
@Bean
public Retrofit initRetrofit(){
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
//.addInterceptor(new TokenInterceptor(stringRedisTemplate, properties))
.connectTimeout(timeout, TimeUnit.SECONDS)
.writeTimeout(timeout, TimeUnit.SECONDS)
.readTimeout(timeout, TimeUnit.SECONDS)
.build();
return new Retrofit.Builder()
.baseUrl(host)
.client(client)
.addConverterFactory(JacksonConverterFactory.create(JsonUtil.getInstance()))
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build();
}
@GET("/xxx/xx/xx/aaa") Call> getTaxPayer(@Query("shxydm") String code);
扫一扫访问 Blade技术社区 移动端