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. JPanel添加键盘监听事件

    因为在自己的游戏需求中谢了要用键盘控制飞机的移动,所以用到键盘监听事件,但是使用了JPanel之后添加了键盘监听事件,按相应的方向键飞机并没有反应.但是如果是为JFrame的内容面板加则会有反应. 为 ...

  2. MySQL 服务启动y异常: 本地无法启动MySQL服务,报的错误:1067,进程意外终止---解决

    启动MySQL后,几秒钟后直接报错了 然后在事件查看器中发现了几条错误信息 Can't start server: Bind on TCP/IP port: No such file or direc ...

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

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

  4. [转][C#]Web.config 相关配置

    设置默认首页 <?xml version="1.0" encoding="UTF-8"?> <configuration> <sy ...

  5. 廖雪峰Java3异常处理-2断言和日志-2使用JDK Logging

    1.日志 为了取代System.out.println() 可以设置输出样式 可以设置输出级别,禁止某些级别输出 可以被重定向到文件 可以按包名控制日志级别 2.JDK内置Logging 在java. ...

  6. Linux下统计局域网流量

    1:统计10.86.0.0/16网段的内网流量情况 将下面脚本保存成文件traffic-lan.sh(运行后需要等待10秒抓包) tcpdump -nqt src net and dst net ! ...

  7. [UE4]小地图UI设计

    一.新建一个名为TestMiniMap的UserWidget用来使用小地图StaticMiniMap. 二.在左侧“User Created”面板中可以看到除自身以外的其他所有用户创建的UserWid ...

  8. YzmCMSV3.1 | 代码审计

    YzmCMSV3.1 | 代码审计 这次审计 yzmcms . YzmCMS采用OOP(面向对象)方式自主开发的框架.框架易扩展,是一款高效开源的内容管理系统,产品基于PHP+Mysql架构,可运行在 ...

  9. 第9章 应用层(6)_SMTP和POP3/IMAP协议

    7. 电子邮件 7.1 电子邮件发送和接收过程 (1)图解电子邮件的发送 ①一个电子邮件系统应具备三个主要组成构件:A用户代理(如Outlook).B邮件服务器.C邮件发送和接收协议(分别为SMTP和 ...

  10. boost 学习笔记 2: timer

    boost 学习笔记 2: timer copy from:http://einverne.github.io/post/2015/12/boost-learning-note-2.html 1:ti ...