博客
关于我
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/

    你可能感兴趣的文章
    Objective-C实现求众数(附完整源码)
    查看>>
    Objective-C实现求曲线在某点的导数(附完整源码)
    查看>>
    Objective-C实现求最大公约数 (GCD)的算法(附完整源码)
    查看>>
    Objective-C实现测试信用卡号码有效性credit card validator的算法(附完整源码)
    查看>>
    Objective-C实现深度优先搜索递归算法(附完整源码)
    查看>>
    Objective-C实现牛顿下山法(附完整源码)
    查看>>
    Objective-C实现牛顿插值法(附完整源码)
    查看>>
    Objective-C实现牛顿法算法(附完整源码)
    查看>>
    Objective-C实现状态模式(附完整源码)
    查看>>
    Objective-C实现狄克斯特拉算法(附完整源码)
    查看>>
    Objective-C实现生成正态分布数据(附完整源码)
    查看>>
    Objective-C实现用二维数组实现矩阵的转置(附完整源码)
    查看>>
    Objective-C实现用半正弦公式计算两个坐标之间的距离算法 (附完整源码)
    查看>>
    Objective-C实现电子词典(附完整源码)
    查看>>
    Objective-C实现离散傅里叶变换(附完整源码)
    查看>>
    Objective-C实现移位密码加解密(附完整源码)
    查看>>
    Objective-C实现程序暂停(附完整源码)
    查看>>
    Objective-C实现程序自动更新(附完整源码)
    查看>>
    Objective-C实现米到英尺的转换算法(附完整源码)
    查看>>
    Objective-C实现粒子群算法(附完整源码)
    查看>>