首先在A服务写好接口 新建这几个包跟类
@FeignClient(contextId = "remoteSysDictService", value = ServiceNameConstants.AMS_SERVICE, fallbackFactory = RemoteSysDictServiceFallbackFactory.class) public interface RemoteSysDictService { @GetMapping("/sysdict/getOwsInfromByType") R getOwsInfromByType(); } @Slf4j @Component public class RemoteSysDictServiceFallbackImpl implements RemoteSysDictService { @Override public R getOwsInfromByType() { return null; } } @Component public class RemoteSysDictServiceFallbackFactory implements FallbackFactory<RemoteSysDictService> { @Override public RemoteSysDictService create(Throwable cause) { RemoteSysDictServiceFallbackImpl remoteSysDictServiceFallback = new RemoteSysDictServiceFallbackImpl(); return remoteSysDictServiceFallback; } }在resource添加spring.factories 配置路径 在B服务直接调用即可