@AutoConfigureAfter(name="org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration")
@ConditionalOnClass(value={okhttp3.ConnectionPool.class,org.springframework.web.client.RestTemplate.class})
@EnableConfigurationProperties(value=OkHttp3ConnectionPoolProperties.class)
@ConditionalOnProperty(prefix="myoss-cloud.ok-http3.connection-pool",
value="enabled",
matchIfMissing=false)
@ConditionalOnWebApplication
@Configuration
public class RestTemplate4OkHttp3ClientAutoConfiguration
extends Object
需要在项目中的 application.yml 中添加下面的属性启用此配置
myoss-cloud.ok-http3.connection-pool.enabled = false
OkHttp3ConnectionPoolProperties| Modifier and Type | Class and Description |
|---|---|
static class |
RestTemplate4OkHttp3ClientAutoConfiguration.SpringCloudProjectAutoConfiguration
Spring Cloud 项目,RestTemplate 自动配置
LoadBalancer拦截器,默认会注册:
LoadBalancerClientRequestInterceptor |
| Constructor and Description |
|---|
RestTemplate4OkHttp3ClientAutoConfiguration(OkHttp3ConnectionPoolProperties properties)
初始化 OkHttp3连接池属性配置
|
public RestTemplate4OkHttp3ClientAutoConfiguration(OkHttp3ConnectionPoolProperties properties)
properties - OkHttp3连接池属性配置@ConditionalOnMissingBean(name="restTemplate4OkHttp3ConnectionPool") @Bean(name="restTemplate4OkHttp3ConnectionPool") public okhttp3.ConnectionPool restTemplate4OkHttp3ConnectionPool()
restTemplate4OkHttp3(com.alibaba.fastjson.support.config.FastJsonConfig, okhttp3.ConnectionPool, java.util.List<okhttp3.Interceptor>, java.util.List<okhttp3.Interceptor>, org.springframework.beans.factory.ObjectProvider<app.myoss.cloud.web.http.loadbalancer.LoadBalancerClientRequestInterceptor>),使用 spring 管理,方便项目中替换此对象或者获取此对象@ConditionalOnMissingBean(name="restTemplate4OkHttp3Interceptor") @Bean(name="restTemplate4OkHttp3Interceptor") public List<okhttp3.Interceptor> restTemplate4OkHttp3Interceptor()
restTemplate4OkHttp3(com.alibaba.fastjson.support.config.FastJsonConfig, okhttp3.ConnectionPool, java.util.List<okhttp3.Interceptor>, java.util.List<okhttp3.Interceptor>, org.springframework.beans.factory.ObjectProvider<app.myoss.cloud.web.http.loadbalancer.LoadBalancerClientRequestInterceptor>),使用 spring 管理,方便项目中替换此对象或者获取此对象@ConditionalOnMissingBean(name="restTemplate4OkHttp3NetworkInterceptor") @Bean(name="restTemplate4OkHttp3NetworkInterceptor") public List<okhttp3.Interceptor> restTemplate4OkHttp3NetworkInterceptor()
restTemplate4OkHttp3(com.alibaba.fastjson.support.config.FastJsonConfig, okhttp3.ConnectionPool, java.util.List<okhttp3.Interceptor>, java.util.List<okhttp3.Interceptor>, org.springframework.beans.factory.ObjectProvider<app.myoss.cloud.web.http.loadbalancer.LoadBalancerClientRequestInterceptor>),使用 spring 管理,方便项目中替换此对象或者获取此对象@ConditionalOnMissingBean(name="restTemplate4OkHttp3")
@Bean(name="restTemplate4OkHttp3")
public org.springframework.web.client.RestTemplate restTemplate4OkHttp3(com.alibaba.fastjson.support.config.FastJsonConfig defaultFastJsonConfig,
okhttp3.ConnectionPool restTemplate4OkHttp3ConnectionPool,
List<okhttp3.Interceptor> restTemplate4OkHttp3Interceptor,
List<okhttp3.Interceptor> restTemplate4OkHttp3NetworkInterceptor,
org.springframework.beans.factory.ObjectProvider<LoadBalancerClientRequestInterceptor> loadBalancerClientRequestInterceptorProvider)
defaultFastJsonConfig - 参考:
FastJsonAutoConfiguration.defaultFastJsonConfig()restTemplate4OkHttp3ConnectionPool - 参考:
restTemplate4OkHttp3ConnectionPool()restTemplate4OkHttp3Interceptor - 参考:
restTemplate4OkHttp3Interceptor()restTemplate4OkHttp3NetworkInterceptor - 参考:
restTemplate4OkHttp3NetworkInterceptor()loadBalancerClientRequestInterceptorProvider - RestTemplate拦截器Copyright © 2018–2019. All rights reserved.