1.引用pom

     <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
<version>1.4.6.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.1.1.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>

2.修改yml

server:
port: 80 eureka:
client:
register-with-eureka: false
service-url:
detaultZone: http://eureka7001.com:7001/eureka/

3.配置类

package com.service.config;

import com.netflix.loadbalancer.IRule;
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(){ return new RetryRule();
}
}

4.启动类

@SpringBootApplication
@EnableEurekaClient
public class Dept_Custor {
public static void main(String[] args){
SpringApplication.run(Dept_Custor.class,args);
}
}

SPring cloud (3)A Ribbon 负载均衡 配置初步的更多相关文章

  1. spring cloud: zuul(三): ribbon负载均衡配置

    zuul的routes配置下path/url组合不支持负载均衡 下面介绍zuul的routes配置下的path/serviceId负载均衡配置 spring-boot-user微服务开启了:7901, ...

  2. Spring Cloud微服务Ribbon负载均衡/Zuul网关使用

    客户端负载均衡,当服务节点出现问题时进行调节或是在正常情况下进行 服务调度.所谓的负载均衡,就是当服务提供的数量和调用方对服务进行 取舍的调节问题,在spring cloud中是通过Ribbon来解决 ...

  3. spring boot 2.0 ribbon 负载均衡配置

    1.pom.xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId ...

  4. spring-cloud: eureka之:ribbon负载均衡配置(一)

    spring-cloud: eureka之:ribbon负载均衡配置(一) 比如我有: 一个eureka服务:8761 两个user用户服务: 7900/7901端口 一个movie服务:8010 1 ...

  5. Spring Cloud 客服端负载均衡 Ribbon

    一.简介   Spring Cloud Ribbon 是一个基于Http和TCP的客服端负载均衡工具,它是基于Netflix Ribbon实现的.它不像服务注册中心.配置中心.API网关那样独立部署, ...

  6. SpringCloud之Ribbon负载均衡配置

    一.负载均衡解决方案分类及特征 业界主流的负载均衡解决方案有: 1.1 集中式负载均衡 即在客户端和服务端之间使用独立的负载均衡设施(可以是硬件,如F5, 也可以是软件,如nginx), 由该设施负责 ...

  7. Spring Cloud Ribbon负载均衡配置类放在Spring boot主类同级增加Exclude过滤后报Field config in com.cloud.web.controller.RibbonConfiguration required a bean of type 'com.netflix.client.config.IClientConfig' that could not b

    环境: Spring Cloud:Finchley.M8 Spring Boot:2.0.0.RELEASE 目录结构: 可以看到代码第13行的注释,我已经在@ComponentScan注解中添加了E ...

  8. 2.【Spring Cloud Alibaba】实现负载均衡-Ribbon

    负载均衡的两种方式 如何实现负载均衡 目前已经实现让A总能找到B,如何实现负载均衡 负载均衡的两种方式 服务器端负载均衡 客户端负载均衡 使用Ribbo实现负载均衡 Ribbon是什么 ==Netfl ...

  9. Spring Cloud ---- 服务消费与负载均衡(Rest + Ribbon )

    上一篇主要写了基于Eurake的服务的注册,主要就是创建注册中心,创建服务者,将服务者注册到注册中心,完成服务的暴露.这一篇主要写服务的消费与服务消费的负载均衡. 服务的调用方式有两种,Rest + ...

随机推荐

  1. LeetCode——3. Longest Substring Without Repeating Characters

    一.题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters 二.题目大意: 给定一个字符串, ...

  2. JS属性描述符之Object.defineProperty()定义对象属性特性

    一.Object.defineProperty的作用 用来给对象新增属性,和修改对象中的属性. 二.JS对象中的描述符 js对象中两种属性描述符:数据描述符和存取描述符(访问描述符). 注意事项: 1 ...

  3. 使用模板引擎artTemplate的几个问题总结

    一.Template not found 有的时候模板写的并没有问题,可就是找不到.这时候可能是<script>加载顺序问题,模板渲染在模板加载完成之前先执行了,调整<script& ...

  4. PAT 乙级 1078 字符串压缩与解压 (20)

    文本压缩有很多种方法,这里我们只考虑最简单的一种:把由相同字符组成的一个连续的片段用这个字符和片段中含有这个字符的个数来表示.例如 ccccc 就用 5c 来表示.如果字符没有重复,就原样输出.例如 ...

  5. PAT 乙级 1069 微博转发抽奖(20) C++版

    1069. 微博转发抽奖(20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 小明PAT考了满分,高兴之余决定 ...

  6. 廖雪峰Java2面向对象编程-2数据封装-1方法

    1.数据封装 一个class可以包含多个field.直接把field用public暴露给外部可能破坏了封装,例如传入不合理的数值(年龄填入1000).如下 public class Person { ...

  7. Windows和pthread中提供的自旋锁

    Windows和POSIX中都提供了自旋锁,我们也可以通过C++11的atomic来实现自旋锁.那么两者性能上面是什么关系?先引入实现代码: #ifndef __spinlock_h__ #defin ...

  8. 0009 - WebFlux

    1.概述 大多数场景使用MVC都是阻塞式的,WebFlux使用的场景是异步非阻塞的 响应式编程是基于异步和事件驱动的非阻塞程序,只是垂直通过在JVM内启动少量线程扩展,而不是水平通过集群扩展. Spr ...

  9. postgresql数据库常用操作命令及SQL语言

    (1)登录 peng@peng-virtual-machine:~$ sudo -u postgres psql 以用户postgres身份登录,postgres为用户名,可有多个用户,登录时会要求输 ...

  10. 逻辑运算符&逻辑短路

    (1)and 逻辑与 全真则真,一假则假 print(True and True) #True print(False and True) #False print(False and False) ...