zoukankan      html  css  js  c++  java
  • Eureka使用总结

    Eureka

    使用eureka的步骤

    1. 搭建Eureka server

      1. 创建工程子模块

      2. 导入坐标

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>
      3. 配置application.yml

        server:
          port: 9000
        eureka:
          instance:
            hostname: localhost
          client:
            register-with-eureka: false
            fetch-registry: false
            service-url:
              defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

        registerWithEureka: 是否将自己注册到Eureka服务中,本身就是所有无需注册
        fetchRegistry : 是否从Eureka中获取注册信息
        serviceUrlEureka: 客户端与Eureka服务端进行交互的地址

      4. 配置启动类(在启动类上添加注解)

        @EnableEurekaServer //激活Eureka Server端配置
      5. 启动。打开浏览器访问http://localhost8761即可进入EurekaServer内置的管理控制台

    2. 将服务提供者注册到Eureka Server上

      1. 引入Eureka Client的坐标

        <dependencies>
        <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-commons</artifactId>
        </dependency>
        <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        </dependencies>
      2. 修改application.yml添加Eureka Server的信息

        eureka:
        client:
        serviceUrl: # eureka server的路径
        defaultZone: http://localhost:8761/eureka/
        instance:
        prefer-ip-address: true #使用ip注册
      3. 修改启动类,添加服务发现的支持(可选)

        添加注解:@EnableDiscoveryClient@EnableEurekaClient

        从Spring Cloud Edgware版本开始, @EnableDiscoveryClient 或 @EnableEurekaClient 可省略。只需加上相关依赖,并进行相应配置,即可将微服务注册到服务发现组件上。

    3. 服务消费者通过注册中心获取服务列表,并调用

  • 相关阅读:
    Android与js交互实例
    动态规划-最长公共子序列
    android调用js
    比特币不是虚拟货币,这是一个真实世界----李笑来
    Linux进程同步之POSIX信号量
    编程至死第0天
    JMX操作ActiveMQ(2)
    Oracle层次查询和with函数的使用
    boost::asio async_write也不能保证一次发完所有数据 一
    解决Eclipse一直loading workbench无法启动的问题
  • 原文地址:https://www.cnblogs.com/friend-c/p/15089990.html
Copyright © 2011-2022 走看看