博客
关于我
spring cloud入门,eureka服务注册和发现,ribbon负载均衡,hystrix熔断
阅读量:349 次
发布时间:2019-03-04

本文共 2975 字,大约阅读时间需要 9 分钟。

??????Spring Cloud??????

??????????????????????????????????????????????????????????????????????????????????

??????????

?????????????

  • ???????????????????????????
  • ???????????????????
  • ????????????????????
  • ?????????????????????

Spring Cloud?????

Spring Cloud???????????????????????????

1. ????????Eureka?

Eureka ?Spring Cloud??????????????????Eureka???????????????????????????????????

2. ???????Zuul?

Zuul????????????????????????????????????????????????????????????

3. ?????Ribbon?

Ribbon?????????????????????????????????????????????????????????????????

4. ???????Hystrix?

Hystrix?????????????????????Hystrix???????????????????????????????????

?????Eureka????

1. ??Eureka Server

  • POM???
  • org.springframework.cloud
    spring-cloud-starter-netflix-eureka-server
    1. ?????application.yml??
    2. server:  port: 8081eureka:  instance:    prefer-ip-address: true    hostname: leo-node  client:    register-with-eureka: false    fetch-registry: false    service-url:      defaultZone: http://${eureka.instance.hostname}:8082/eureka
      1. ????
      2. @SpringBootApplication@EnableEurekaServerpublic class EurekaServerApplication {    public static void main(String[] args) {        SpringApplication.run(EurekaServerApplication.class);    }}

        2. ????Eureka??

        ?IDE???????Eureka Server???????????????????????????????????Eureka??????????

        ????????Eureka???

        1. POM??

        org.springframework.cloud
        spring-cloud-starter-netflix-eureka-client

        2. ?????application.yml?

        eureka:  client:    service-url:      defaultZone: http://leo-node:8081/eureka    register-with-eureka: true    fetch-registry: trueserver:  port: 8091

        3. ???

        @SpringBootApplication@EnableEurekaClientpublic class ServiceProviderApplication {    public static void main(String[] args) {        SpringApplication.run(ServiceProviderApplication.class);    }}

        ????????Ribbon????

        1. POM??

        org.springframework.cloud
        spring-cloud-starter-netflix-ribbon

        2. ?????application.yml?

        eureka:  client:    service-url:      defaultZone: http://leo-node:8081/eurekaserver:  port: 9000

        3. ???????

        @Configurationpublic class RibbonConfig {    @LoadBalanced    @Bean    public RestTemplate restTemplate() {        return new RestTemplate();    }}

        4.CONTROLLER

        @RestController@RequestMapping("/consumer/ribbon")public class ConsumerController {    @Value("${server.port}")    private String port;    @Autowired    private RestTemplate restTemplate;    @RequestMapping("/sayHello")    public String test() {        return restTemplate.getForObject("http://service-provider-001/provider/sayHello", String.class);    }}

        ????

        ????????????????????????

      3. ??Eureka Server??????????????????
      4. ???????????????Eureka Server???????
      5. ??????????Ribbon?????????Hystrix???????????
      6. ????

        • ??????????????????Eureka Server?????????????
        • ???????Ribbon????????????????
        • ?????Hystrix????????????????????

        ???????????????Spring Cloud??????????????????????????

    转载地址:http://vyme.baihongyu.com/

    你可能感兴趣的文章
    Nginx 反向代理 MinIO 及 ruoyi-vue-pro 配置 MinIO 详解
    查看>>
    Nginx 反向代理解决跨域问题
    查看>>
    Nginx 反向代理配置去除前缀
    查看>>
    nginx 后端获取真实ip
    查看>>
    Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
    查看>>
    nginx 常用配置记录
    查看>>
    Nginx 我们必须知道的那些事
    查看>>
    Nginx 的 proxy_pass 使用简介
    查看>>
    Nginx 的配置文件中的 keepalive 介绍
    查看>>
    Nginx 负载均衡与权重配置解析
    查看>>
    Nginx 负载均衡详解
    查看>>
    nginx 配置 单页面应用的解决方案
    查看>>
    nginx 配置~~~本身就是一个静态资源的服务器
    查看>>
    Nginx下配置codeigniter框架方法
    查看>>
    nginx添加模块与https支持
    查看>>
    Nginx的Rewrite正则表达式,匹配非某单词
    查看>>
    Nginx的使用总结(一)
    查看>>
    Nginx的是什么?干什么用的?
    查看>>
    Nginx访问控制_登陆权限的控制(http_auth_basic_module)
    查看>>
    nginx负载均衡器处理session共享的几种方法(转)
    查看>>