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,出现以下内容,则启动成功




  • 相关阅读:
    day 29-2 socket 文件传输、udp协议
    day 29-1 socket
    day 28-1 元类、异常处理
    day 27-1 反射、内置方法
    day 26-1 property、绑定与非绑定方法
    day 25-1 接口类、抽象类、多态
    day 24-1 继承
    day 23-1 类的命名空间、组合
    day 22
    PyMySQL操作mysql数据库(py3必学)
  • 原文地址:https://www.cnblogs.com/bigdatadiary/p/13215419.html
Copyright © 2011-2022 走看看