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

    你可能感兴趣的文章
    Node-RED中实现HTML表单提交和获取提交的内容
    查看>>
    Node-RED中将CSV数据写入txt文件并从文件中读取解析数据
    查看>>
    Node-RED中建立TCP服务端和客户端
    查看>>
    Node-RED中建立Websocket客户端连接
    查看>>
    Node-RED中解析高德地图天气api的json数据显示天气仪表盘
    查看>>
    Node-RED中通过node-red-ui-webcam节点实现访问摄像头并截取照片预览
    查看>>
    Node-RED安装图形化节点dashboard实现订阅mqtt主题并在仪表盘中显示温度
    查看>>
    Node-RED订阅MQTT主题并调试数据
    查看>>
    node-request模块
    查看>>
    Node.js 8 中的 util.promisify的详解
    查看>>
    node.js url模块
    查看>>
    Node.js Web 模块的各种用法和常见场景
    查看>>
    Node.js 函数是什么样的?
    查看>>
    Node.js 切近实战(七) 之Excel在线(文件&文件组)
    查看>>
    node.js 初体验
    查看>>
    Node.js 历史
    查看>>
    Node.js 在个推的微服务实践:基于容器的一站式命令行工具链
    查看>>
    Node.js 实现类似于.php,.jsp的服务器页面技术,自动路由
    查看>>
    Node.js 异步模式浅析
    查看>>
    node.js 怎么新建一个站点端口
    查看>>