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

    你可能感兴趣的文章
    nvidia-smi 参数详解
    查看>>
    Nvidia驱动失效,采用官方的方法重装更快
    查看>>
    nvmw安装node-v4.0.0之后版本的临时解决办法
    查看>>
    nvm切换node版本
    查看>>
    nvm安装 出现 Error retrieving “http://xxxx/SHASUMS256.txt“: HTTP Status 404 解决方法
    查看>>
    nvm安装以后,node -v npm 等命令提示不是内部或外部命令 node多版本控制管理 node多版本随意切换
    查看>>
    NXLog采集windows日志配置conf文件
    查看>>
    ny540 奇怪的排序 简单题
    查看>>
    NYOJ -216 A problem is easy
    查看>>
    NYOJ 1066 CO-PRIME(数论)
    查看>>
    NYOJ 737:石子合并(一)(区间dp)
    查看>>
    nyoj 91 阶乘之和(贪心)
    查看>>
    nyoj------203三国志
    查看>>
    NYOJ-525 一道水题
    查看>>
    NYOJ127星际之门(一)
    查看>>
    nyoj58 最少步数
    查看>>
    N皇后问题
    查看>>
    N皇后问题
    查看>>
    n种方式教你用python读写excel等数据文件
    查看>>
    OAuth 2.0 MAC Tokens
    查看>>