• erueka集群demo


    pom中导入一个依赖

       <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
                </dependency>
    
        </dependencies>

    创建一个启动类

    @SpringBootApplication
    @EnableEurekaServer
    public class AppStart {
        public static void main(String[] args) {
            SpringApplication.run(AppStart.class, args);
        }
    }

    创建配置文件

    #内置的tomcat服务启动监听端口号
    server:
      port: 6001
    #应用名称
    #spring:
    #  application:
    #    name: EurekaServer01
    #EurekaServer配置
    eureka:
      instance:
        hostname: eureka6001.com
      client:
        register-with-eureka: false #此EurekaServer不在注册到其他的注册中心
        fetch-registry: false       #不在从其他中心中心拉取服务器信息
        service-url:
          defaultZone: http://eureka6002.com:6002/eureka #注册中心访问地址

    6002与6001相似 配置文件 稍作修改即可

    在03_provider中的修改(类似于中介的存在)

    pom中再添加下面的依赖

     <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>

    主启动类中添加下面代码 主要是@EnableEurekaClinet注解

    @MapperScan("com.offcn.springcloud.mapper")
    @SpringBootApplication
    @EnableEurekaClient             
    public class ProductProvider_8001 {
        public static void main(String[] args) {
    
            SpringApplication.run(ProductProvider_8001.class,args);
        }
    }

    配置文件中添加下面代码

    #EurekaServer配置
    eureka:
      client:
        register-with-eureka: true #此EurekaServer不在注册到其他的注册中心
        fetch-registry: true       #不在从其他中心中心拉取服务器信息
        service-url:
          defaultZone: http://eureka6001.com:6001/eureka,http://eureka6002.com:6002/eureka #注册中心访问地址
  • 相关阅读:
    P3391 文艺平衡树
    隔离村庄(树形dp[01背包])
    cmd指令集
    vs的使用
    博客园第一天
    蓝桥杯 小生物的逃逸 模拟
    蓝桥杯 自行车停放 双向链表
    c++字符数组函数总结
    蓝桥杯 石子游戏 贪心
    蓝桥杯 最大获利 模拟
  • 原文地址:https://www.cnblogs.com/proyuan/p/11824388.html
Copyright © 2020-2023  润新知