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




  • 相关阅读:
    map和cmath
    优先级队列queue
    algorithm头文件(sort 函数)
    12
    利用sqlmap简单注入dvwa
    集群高可用之lvs+keepalive
    集群高可用之lvs
    zabbix的配置之新版微信报警(二)
    Python升级版本2.6到2.7
    zabbix的安装(一)监控os资源:内存,cpu,io,负载,带宽
  • 原文地址:https://www.cnblogs.com/bigdatadiary/p/13215419.html
Copyright © 2011-2022 走看看