pom.xml
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
yml配置
feign:sentinel:enabled: true
ProductFeignService (作用是当远程调用服务product-service发生异常的时候会执行ProductFeignFallBackService 的 get方法)
@FeignClient(value = "product-service", path = "/product", fallback = ProductFeignFallBackService.class)
public interface ProductFeignService {@RequestMapping("/{id}")public String get(@PathVariable Integer id);}
ProductFeignFallBackService
public class ProductFeignFallBackService implements ProductFeignService {@Overridepublic String get(Integer id) {return "进入降级";}
}