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

posted @ 2019-12-13 16:15  尘世的流浪人  阅读(266)  评论(0编辑  收藏  举报