♻️ 重构 feign 导入支持单体版本通过SPI 导入

This commit is contained in:
冷冷 2024-04-07 13:15:21 +08:00
parent d302fb71f1
commit 66379e728f
3 changed files with 53 additions and 43 deletions

View File

@ -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 {

View File

@ -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,13 +29,13 @@ 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 {};
@ -49,6 +47,7 @@ public @interface EnablePigFeignClients {
* <p>
* Use {@link #basePackageClasses()} for a type-safe alternative to String-based
* package names.
*
* @return the array of 'basePackages'.
*/
String[] basePackages() default {"com.pig4cloud.pig"};
@ -59,6 +58,7 @@ public @interface EnablePigFeignClients {
* <p>
* 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 {};
@ -75,6 +75,7 @@ public @interface EnablePigFeignClients {
/**
* List of classes annotated with @FeignClient. If not empty, disables classpath
* scanning.
*
* @return
*/
Class<?>[] clients() default {};

View File

@ -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