@Retention(value=RUNTIME) @Target(value=TYPE) @Documented @Inherited public @interface RetrofitClient
| 限定符和类型 | 可选元素和说明 |
|---|---|
String |
baseUrl
基础URL(协议是必需的)。
|
Class<? extends retrofit2.CallAdapter.Factory>[] |
callAdapterFactories
适用于当前接口的调用适配器工厂,优先级比全局调用适配器工厂更高。
|
int |
callTimeoutMs
Sets the default timeout for complete calls.
|
int |
connectTimeoutMs
Sets the default connect timeout for new connections.
|
Class<? extends retrofit2.Converter.Factory>[] |
converterFactories
适用于当前接口的转换器工厂,优先级比全局转换器工厂更高。
|
Class<? extends ErrorDecoder> |
errorDecoder
当前接口采用的错误解码器,当请求发生异常或者收到无效响应结果的时候,将HTTP相关信息解码到异常中,无效响应由业务自己判断。
|
Class<?> |
fallback
Fallback class for the specified retrofit client interface.
|
Class<?> |
fallbackFactory
Define a fallback factory for the specified Feign client interface.
|
String |
path
Path prefix to be used by all method-level mappings.
|
int |
readTimeoutMs
Sets the default read timeout for new connections.
|
String |
serviceId
The name of the service.
|
String |
sourceOkHttpClient
源OkHttpClient,根据该名称到#
SourceOkHttpClientRegistry查找对应的OkHttpClient来构建当前接口的OkhttpClient。 |
boolean |
validateEagerly
When calling
Retrofit.create(Class) on the resulting Retrofit instance, eagerly validate the
configuration of all methods in the supplied interface. |
int |
writeTimeoutMs
Sets the default write timeout for new connections.
|
public abstract String baseUrl
An absolute URL (the protocol is necessary). Can be specified as property key, eg: ${propertyKey}. If baseUrl is not configured, you must configure serviceId and path optional configuration.
public abstract String serviceId
public abstract String path
public abstract Class<? extends retrofit2.Converter.Factory>[] converterFactories
Converter factory for the current interface, higher priority than global converter factory. The converter instance is first obtained from the Spring container. If it is not obtained, it is created by reflection.
public abstract Class<? extends retrofit2.CallAdapter.Factory>[] callAdapterFactories
callAdapter factory for the current interface, higher priority than global callAdapter factory. The converter instance is first obtained from the Spring container. If it is not obtained, it is created by reflection.
public abstract Class<?> fallback
public abstract Class<?> fallbackFactory
RetrofitClient.The fallback factory must be a valid spring bean.
bean.public abstract Class<? extends ErrorDecoder> errorDecoder
ErrorDecoder,然后配置在这里。
The error decoder used in the current interface will decode HTTP related information into the exception when an exception occurs in the request or an invalid response result is received.
The invalid response is determined by the business itself.
In general, the invalid response corresponding to each service is different, you can customize the corresponding ErrorDecoder, and then configure it here.
public abstract boolean validateEagerly
Retrofit.create(Class) on the resulting Retrofit instance, eagerly validate the
configuration of all methods in the supplied interface.public abstract String sourceOkHttpClient
SourceOkHttpClientRegistry查找对应的OkHttpClient来构建当前接口的OkhttpClient。public abstract int connectTimeoutMs
public abstract int readTimeoutMs
public abstract int writeTimeoutMs
public abstract int callTimeoutMs
Copyright © 2024. All rights reserved.