spring cloud ribbon 配置负载均衡


@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
public class GoodsOrderApplication {

    @LoadBalanced
    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

    @Bean
    public IRule setRule(){
        // RetryRule 可以换为为 RandomRule():随机调用服务
        // 默认为轮询 调用 
        return new RetryRule();
    }
    public static void main(String[] args) {
        SpringApplication.run(GoodsOrderApplication.class,args);
    }

}

参考:
https://blog.csdn.net/liuchuanhong1/article/details/54691566

原文地址:https://www.cnblogs.com/wanthune/p/12035766.html