SpringCloudAlibaba Feign

Feign实现文件上传

Feign实现文件上传
https://blog.csdn.net/weixin_45051743/article/details/108208332

Fegin的介绍

Feign 是一个声明式REST Web Service服务客户端,可以处理微服务间的Web服务调用。他使用声明式注解@FeignClient+接口的形式形成去调用服务的。
相比HTTP客户端,Feign通过代理模式屏蔽了调用方与底层HTTPClient技术耦合的调用细节。Feign的调用就像使用本地方法调用完成服务的请求。

支持集成Hystrix

Feign支持集成Hystrix,以实现对远程服务的容错处理,例如服务降级、断路器等。

加入pom依赖


     org.springframework.cloud
     spring-cloud-starter-openfeign


	org.springframework.cloud
	spring-cloud-starter-loadbalancer

@EnableFeignClients 启动类加入注解

@SpringBootApplication

@EnableFeignClients    //开启fegin
public class OrderApplication {···}

FeignService

创建商品服务的api接口

@FeignClient(value = “common-service”, contextId = "smsFeignService", fallback = SmsFeignServiceFallback.class)
public interface SmsFeignService {

    /** 发送位验证码 */
    @PostMapping("/common/service/sms/sendCode")
    public ResEntity sendCode6(@RequestParam("phone") String phone);
}

FeignServiceFallback

@Service
public class SmsFeignServiceFallback implements SmsFeignService {
    @Override
    public ResEntity sendCode6(String phone) { return Res.fail(ResEntity.Err.FEIGN_EXCEPTION); }
}

其他

Feign请求方式
https://blog.csdn.net/Zach1Lavine/article/details/124631779

Gateway跨域处理
https://blog.csdn.net/weixin_43730516/article/details/127040628

Spring Cloud Feign使用记录及携带token请求
https://www.cnblogs.com/goloving/p/13667100.html

Feign全局配置自定义和支持的配置项
https://developer.aliyun.com/article/1048347

原理
https://cloud.tencent.com/developer/article/2143634

你可能感兴趣的:(springcloud)