From 66379e728fd8aa4f38c43707ca01310181fb962b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= <2270033969@qq.com> Date: Sun, 7 Apr 2024 13:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E9=87=8D=E6=9E=84=20feign?= =?UTF-8?q?=20=E5=AF=BC=E5=85=A5=E6=94=AF=E6=8C=81=E5=8D=95=E4=BD=93?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E9=80=9A=E8=BF=87SPI=20=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/PigFeignAutoConfiguration.java | 3 + .../annotation/EnablePigFeignClients.java | 87 ++++++++++--------- ...mework.cloud.openfeign.FeignClient.imports | 6 ++ 3 files changed, 53 insertions(+), 43 deletions(-) create mode 100644 pig-upms/pig-upms-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports diff --git a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/PigFeignAutoConfiguration.java b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/PigFeignAutoConfiguration.java index 29f89286..c16957f8 100755 --- a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/PigFeignAutoConfiguration.java +++ b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/PigFeignAutoConfiguration.java @@ -29,8 +29,10 @@ import feign.RequestInterceptor; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.openfeign.PigFeignClientsRegistrar; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Scope; /** @@ -40,6 +42,7 @@ import org.springframework.context.annotation.Scope; * @date 2020-02-12 */ @Configuration(proxyBeanMethods = false) +@Import(PigFeignClientsRegistrar.class) @AutoConfigureBefore(SentinelFeignAutoConfiguration.class) public class PigFeignAutoConfiguration { diff --git a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java index ed97d11a..d0cc7e48 100755 --- a/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java +++ b/pig-common/pig-common-feign/src/main/java/com/pig4cloud/pig/common/feign/annotation/EnablePigFeignClients.java @@ -18,8 +18,6 @@ package com.pig4cloud.pig.common.feign.annotation; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.FeignClientsConfiguration; -import org.springframework.cloud.openfeign.PigFeignClientsRegistrar; -import org.springframework.context.annotation.Import; import java.lang.annotation.*; @@ -31,52 +29,55 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Documented @EnableFeignClients -@Import(PigFeignClientsRegistrar.class) public @interface EnablePigFeignClients { - /** - * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation - * declarations e.g.: {@code @ComponentScan("org.my.pkg")} instead of - * {@code @ComponentScan(basePackages="org.my.pkg")}. - * @return the array of 'basePackages'. - */ - String[] value() default {}; + /** + * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation + * declarations e.g.: {@code @ComponentScan("org.my.pkg")} instead of + * {@code @ComponentScan(basePackages="org.my.pkg")}. + * + * @return the array of 'basePackages'. + */ + String[] value() default {}; - /** - * Base packages to scan for annotated components. - *

- * {@link #value()} is an alias for (and mutually exclusive with) this attribute. - *

- * Use {@link #basePackageClasses()} for a type-safe alternative to String-based - * package names. - * @return the array of 'basePackages'. - */ - String[] basePackages() default { "com.pig4cloud.pig" }; + /** + * Base packages to scan for annotated components. + *

+ * {@link #value()} is an alias for (and mutually exclusive with) this attribute. + *

+ * Use {@link #basePackageClasses()} for a type-safe alternative to String-based + * package names. + * + * @return the array of 'basePackages'. + */ + String[] basePackages() default {"com.pig4cloud.pig"}; - /** - * Type-safe alternative to {@link #basePackages()} for specifying the packages to - * scan for annotated components. The package of each class specified will be scanned. - *

- * Consider creating a special no-op marker class or interface in each package that - * serves no purpose other than being referenced by this attribute. - * @return the array of 'basePackageClasses'. - */ - Class[] basePackageClasses() default {}; + /** + * Type-safe alternative to {@link #basePackages()} for specifying the packages to + * scan for annotated components. The package of each class specified will be scanned. + *

+ * Consider creating a special no-op marker class or interface in each package that + * serves no purpose other than being referenced by this attribute. + * + * @return the array of 'basePackageClasses'. + */ + Class[] basePackageClasses() default {}; - /** - * A custom @Configuration for all feign clients. Can contain override - * @Bean definition for the pieces that make up the client, for instance - * {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}. - * - * @see FeignClientsConfiguration for the defaults - */ - Class[] defaultConfiguration() default {}; + /** + * A custom @Configuration for all feign clients. Can contain override + * @Bean definition for the pieces that make up the client, for instance + * {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}. + * + * @see FeignClientsConfiguration for the defaults + */ + Class[] defaultConfiguration() default {}; - /** - * List of classes annotated with @FeignClient. If not empty, disables classpath - * scanning. - * @return - */ - Class[] clients() default {}; + /** + * List of classes annotated with @FeignClient. If not empty, disables classpath + * scanning. + * + * @return + */ + Class[] clients() default {}; } diff --git a/pig-upms/pig-upms-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports b/pig-upms/pig-upms-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports new file mode 100644 index 00000000..cedeeaff --- /dev/null +++ b/pig-upms/pig-upms-api/src/main/resources/META-INF/spring/org.springframework.cloud.openfeign.FeignClient.imports @@ -0,0 +1,6 @@ +com.pig4cloud.pig.admin.api.feign.RemoteClientDetailsService +com.pig4cloud.pig.admin.api.feign.RemoteDictService +com.pig4cloud.pig.admin.api.feign.RemoteLogService +com.pig4cloud.pig.admin.api.feign.RemoteParamService +com.pig4cloud.pig.admin.api.feign.RemoteTokenService +com.pig4cloud.pig.admin.api.feign.RemoteUserService