SpringCloud-Eureka注册中心实现(一)

Eureka注册中心的作用就是管理服务

  1. 新建项目
    选择下图依赖自动导入eureka的依赖
    在这里插入图片描述
    在这里插入图片描述

  2. 配置文件application.properties

    ## server
    server.port=8888
    
    ##eureka
    #指定环境
    eureka.environment=work
    # 设置是否将自己作为客户端注册到注册中心(缺省true)
    # 这里为不需要(查看@EnableEurekaServer注解的源码,会发现它间接用到了@EnableDiscoveryClient)
    eureka.client.register-with-eureka=false
    # 设置是否从注册中心获取注册信息(缺省true)
    # 因为这是一个单点的EurekaServer,不需要同步其它EurekaServer节点的数据,故设为false
    eureka.client.fetch-registry=false
    eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/
    #是否开启自我保护模式,默认为true。
    eureka.server.enable-self-preservation=true
    #续期时间,即扫描失效服务的间隔时间(缺省为60*1000ms)
    eureka.server.eviction-interval-timer-in-ms=10000
    
  3. 启动类

    package com.example.eureka;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @SpringBootApplication
    @EnableEurekaServer
    public class EurekaApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(EurekaApplication.class, args);
        }
    
    }
    
    
  4. 运行项目,显示下面页面则表示成功
    在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值