package com.service.config;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RetryRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class Dept_Config {

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

@Bean
public IRule myRule(){

// RoundRobinRule 轮询
// RandomRule 随机
return new RetryRule();
}
}

自定义Ribbon
1.加载注解

2.配置mySelfRule.class

3.自定义时要实现

 


posted on 2019-03-24 20:43  <meng>  阅读(165)  评论(0)    收藏  举报