sentinel,熔断,限流等异常,可以通过自己编写异常声明类
    nacos:Spring Cloud Alibaba 致力于提供微服务开发的一站式解决方案,Nacos 作为其核心组件之一,可以作为注册中心和配置中心使用;快速实现动态服务发现、服务配置、服务元数据及流量管理。
    OpenFeign的@FeignClient可以解析SpringMVC的@RequestMapping注解的接口,通过动态代理的方式实现服务间通信,并内置Ribbon实现客户端负载均衡的能力。
    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BlockException e) throws Exception {
    String msg = null;
    if(e instanceof FlowException){
    msg = “接口被限流”;
    }else if(e instanceof DegradeException){
    msg = “接口被熔断,稍后再试”;
    }else if(e instanceof ParamFlowException){
    msg = “热点参数限流”;
    }else if(e instanceof SystemBlockException){
    msg = “系统规则限流”;
    }else if(e instanceof AuthorityException){
    msg = “系统授权限流”;
    }
    httpServletResponse.setStatus(500);
    httpServletResponse.setCharacterEncoding(“utf-8”);
    httpServletResponse.setContentType(“application/json;charset=utf-8”);
    ObjectMapper mapper = new ObjectMapper();
    Map map = new HashMap<>();
    map.put(“code”,500);
    map.put(“message”,msg);
    mapper.writeValue(httpServletResponse.getWriter(),map);
    }
    }

    yml配置文件的配置,需要配置nacos的地址和sentinel的地址,
    配置文件参考如下
    spring:
    application:
    name: feign-service
    cloud:
    nacos:
    discovery:
    server-addr: localhost:8848 # 注册中心地址,macos地址
    _sentinel:
    transport:
    dashboard: localhost:8081 #sentinel控制中心地址,默认是8080
    server:
    port: 8088
    feign:
    sentinel:
    enabled: true
    #开启OpenFeign基于Sentinel的限流熔断_

    `