自定义spring cloud gateway 负载均衡

 实现以下的类:自定义获取ServerInstance(服务实例)

public class BalancerFilter extends LoadBalancerClientFilter {


    public BalancerFilter(LoadBalancerClient loadBalancer, LoadBalancerProperties properties) {
        super(loadBalancer, properties);
    }

    @Override
    protected ServiceInstance choose(ServerWebExchange exchange) {
        //自定义服务实例化获取
        ServiceInstance instance = super.choose(exchange);
        return instance;
    }
}

你可能感兴趣的:(java,spring,cloud,gateway,负载均衡)