- * 同步调用执行,直接返回 #{@link Response} 对象
+ * 同步调用执行,直接返回 #{@link Response} 对象。
* Synchronous call execution, directly return #{@link Response} object
- *
+ * 一般情况下,每个服务对应的无效响应各不相同,可以自定义对应的{@link ErrorDecoder},然后配置在这里。
- * 当前http的url路径是否与指定的patterns匹配
+ * 当前http的url路径是否与指定的patterns匹配。
>
* 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 {@link ErrorDecoder}, and then configure it here.
@@ -103,6 +89,14 @@
*/
String poolName() default "default";
+ /**
+ * When calling {@link Retrofit#create(Class)} on the resulting {@link Retrofit} instance, eagerly validate the
+ * configuration of all methods in the supplied interface.
+ *
+ * @return validateEagerly
+ */
+ boolean validateEagerly() default false;
+
/**
* Sets the default connect timeout for new connections. A value of 0 means no timeout,
* otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds.
@@ -130,7 +124,6 @@
*/
int writeTimeoutMs() default -1;
-
/**
* Sets the default timeout for complete calls. A value of 0 means no timeout,
* otherwise values must be between 1 and Integer.MAX_VALUE when converted to milliseconds.
@@ -148,7 +141,6 @@
*/
int pingIntervalMs() default 0;
-
/**
* Configure this client to allow protocol redirects from HTTPS to HTTP and from HTTP to HTTPS.
* Redirects are still first restricted by followRedirects. Defaults to true.
diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java
index 668bc1a..c5fd785 100644
--- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java
+++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitClientScannerRegistrar.java
@@ -15,11 +15,12 @@
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
-import com.github.lianjiatech.retrofit.spring.boot.annotation.RetrofitScan;
+import lombok.extern.slf4j.Slf4j;
/**
* @author 陈添明
*/
+@Slf4j
public class RetrofitClientScannerRegistrar
implements ImportBeanDefinitionRegistrar, ResourceLoaderAware, BeanClassLoaderAware {
@@ -42,6 +43,8 @@ public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionR
}
// Specify the base package for scanning
String[] basePackages = getPackagesToScan(attributes);
+ log.info("Scan the @RetrofitClient annotated interface using the @RetrofitScan configuration. packages={}",
+ Arrays.toString(basePackages));
scanner.registerFilters();
// Scan and register to BeanDefinition
scanner.doScan(basePackages);
diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java
index ef283ca..f114424 100644
--- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java
+++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/RetrofitFactoryBean.java
@@ -20,24 +20,20 @@
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.env.Environment;
import org.springframework.util.Assert;
-import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
-import com.github.lianjiatech.retrofit.spring.boot.annotation.Intercept;
-import com.github.lianjiatech.retrofit.spring.boot.annotation.InterceptMark;
-import com.github.lianjiatech.retrofit.spring.boot.annotation.Intercepts;
-import com.github.lianjiatech.retrofit.spring.boot.annotation.OkHttpClientBuilder;
-import com.github.lianjiatech.retrofit.spring.boot.annotation.RetrofitClient;
import com.github.lianjiatech.retrofit.spring.boot.config.DegradeProperty;
import com.github.lianjiatech.retrofit.spring.boot.config.RetrofitConfigBean;
import com.github.lianjiatech.retrofit.spring.boot.config.RetrofitProperties;
import com.github.lianjiatech.retrofit.spring.boot.degrade.DegradeProxy;
import com.github.lianjiatech.retrofit.spring.boot.degrade.DegradeType;
-import com.github.lianjiatech.retrofit.spring.boot.degrade.FallbackFactory;
import com.github.lianjiatech.retrofit.spring.boot.degrade.sentinel.SentinelDegrade;
import com.github.lianjiatech.retrofit.spring.boot.interceptor.BasePathMatchInterceptor;
+import com.github.lianjiatech.retrofit.spring.boot.interceptor.Intercept;
+import com.github.lianjiatech.retrofit.spring.boot.interceptor.InterceptMark;
+import com.github.lianjiatech.retrofit.spring.boot.interceptor.Intercepts;
import com.github.lianjiatech.retrofit.spring.boot.util.AnnotationExtendUtils;
import com.github.lianjiatech.retrofit.spring.boot.util.AppContextUtils;
import com.github.lianjiatech.retrofit.spring.boot.util.BeanExtendUtils;
@@ -46,8 +42,6 @@
import okhttp3.ConnectionPool;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
-import retrofit2.CallAdapter;
-import retrofit2.Converter;
import retrofit2.Retrofit;
/**
@@ -55,10 +49,7 @@
*/
public class RetrofitFactoryBean
>
* Whether the current http URL path matches the specified patterns
- *
+ * 将响应体内容适配成一个对应的Java类型对象返回,如果http状态码不是2xx,直接抛错!
+ *
+ * @param id id
+ * @return 其他任意Java类型
+ */
+ @GET("person")
+ Result