我搜了一下 加了一个配置 就完事了

feign:
  #hystrix:
   #enabled: true过时了 springcloud2020.0.1改为以下了
  circuitbreaker:
    enabled: true #feign作为客户端使用hystrix必须开启,服务端没有feign所以没有这个.

已经没有前者注解了。现在改为circuitbreaker了

修改之后接口实现类就可以被成功调用,完美。
在这里插入图片描述
在这里插入图片描述

@FeignClient(value = "SentinelServer",configuration = LoadBalancePolicy.class,fallback = OrderServiceFallBackImpl.class)
public interface RemoteOrderService {

    @GetMapping("/order/queryOrderById")
    public Result queryOrderById(@RequestParam("id") int id);


}
@Service
public class OrderServiceFallBackImpl implements RemoteOrderService {
    @Override
    public Result queryOrderById(@RequestParam("id") int id) {
        return new Result(ResultStatus.ERROR.getReturncode(),"远程服务器异常,无法连接","");
    }
}

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐