zoukankan      html  css  js  c++  java
  • springcloud(01)启动Eureka Server,并将其他模块作为Eureka Client启动

    1、进入https://start.spring.io/,创建一个Eureka Server 的springboot项目。

    2、在idea打开项目,删掉src目录,为项目new 一个子 module,将子模块命名为eureka 。再把父模块中的pom文件中Eureka Server的包剪切到子模块中。

    3、在eureka子项目中添加启动类,在启动类中添加@EnableEurekaServer注解。添加application.yml配置文件,在application.yml中加入以下配置: 

    spring:
    application:
    name: eureka
    server:
    port: 8761
    eureka:
    instance:
    hostname: localhost
    client:
    register-with-eureka: false
    fetch-registry: false

    4、启动子项目,打开localhost:8761,显示eureka界面,则完成Eureka Server的启动。
    5、新建一个子模块system,作为eureka client启动。
    6、将子模块system新建完成后,在其application.yml配置以下内容:
    spring:
    application:
    name: system
    server:
    port: 9001
    eureka:
    client:
    service-url:
    defaultZone: http://localhost:8761/eureka/

    7、再system模块的pom文件中添加:
    <dependencies>
    <dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    </dependencies>
    8、启动system模块,打开localhost:8761,出现以下内容,则启动成功




  • 相关阅读:
    GetEnumName 枚举名称 字符串
    拖拽文件
    小米手机Root 刷机
    微软语言 中文 英文 中英文
    MTP
    MD5加密算法全解析
    ORA-28000: the account is locked
    HTTP状态码
    HTTP 消息结构
    @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
  • 原文地址:https://www.cnblogs.com/bigdatadiary/p/13215419.html
Copyright © 2011-2022 走看看