diff --git a/README.md b/README.md index d9c5504..9d33fd1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ gitee项目地址:[https://gitee.com/lianjiatech/retrofit-spring-boot-starter] com.github.lianjiatech retrofit-spring-boot-starter - 2.2.13 + 2.2.14 ``` @@ -63,7 +63,7 @@ gitee项目地址:[https://gitee.com/lianjiatech/retrofit-spring-boot-starter] com.github.lianjiatech retrofit-spring-boot-starter - 2.2.13 + 2.2.14 com.squareup.okhttp3 diff --git a/README_EN.md b/README_EN.md index bb183ae..6093711 100644 --- a/README_EN.md +++ b/README_EN.md @@ -43,7 +43,7 @@ com.github.lianjiatech retrofit-spring-boot-starter - 2.2.13 + 2.2.14 ``` @@ -53,7 +53,7 @@ This project depends on Retrofit-2.9.0, okhttp-3.14.9, and okio-1.17.5 versions. com.github.lianjiatech retrofit-spring-boot-starter - 2.2.13 + 2.2.14 com.squareup.okhttp3 diff --git a/pom.xml b/pom.xml index 90da40a..96212ec 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.lianjiatech retrofit-spring-boot-starter - 2.2.13 + 2.2.14 retrofit-spring-boot-starter retrofit-spring-boot-starter diff --git a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ClassPathRetrofitClientScanner.java b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ClassPathRetrofitClientScanner.java index 487cae2..f65cf7f 100644 --- a/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ClassPathRetrofitClientScanner.java +++ b/src/main/java/com/github/lianjiatech/retrofit/spring/boot/core/ClassPathRetrofitClientScanner.java @@ -59,7 +59,7 @@ protected boolean isCandidateComponent( beanDefinition.getMetadata().getClassName(), classLoader); - return !target.isAnnotation() && legalBaseUrl(target); + return !target.isAnnotation() && (legalBaseUrl(target) || legalServiceId(target)); } catch (Exception ex) { logger.error("load class exception:", ex); } @@ -84,6 +84,23 @@ private boolean legalBaseUrl(Class target) { return true; } + private boolean legalServiceId(Class target) { + final RetrofitClient retrofitClient = target.getAnnotation(RetrofitClient.class); + final String serviceId = retrofitClient.serviceId(); + if (StringUtils.isEmpty(serviceId)) { + logger.warn("No config serviceId! interface={}", target); + return false; + } + + try { + environment.resolveRequiredPlaceholders(serviceId); + } catch (Exception e) { + logger.warn("No config serviceId! interface={}", target); + return false; + } + return true; + } + private void processBeanDefinitions(Set beanDefinitions) { GenericBeanDefinition definition;