【SpringCloud 2021.0.0】5、Eureka构建过程:Server\Client 配置info 自我保护 服务发现 (spring-boot 2.6.3)

1、构建步骤

1)eureka-server

(1)创建Meven工程

springcloud-eureka-7001

(2)导jar包

使用 spring-cloud-starter-netflix-eureka-server

<!-- spring-cloud-starter-eureka-server:已废弃 -->

<!-- spring-cloud-starter-netflix-eureka-server -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<!-- 热部署 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
</dependency>

(3)application.yml

server:
  port: 7001

# Eureka配置
eureka:
  instance:
    # Eureka服务端的实例名字
    hostname: localhost

  client:
    # 表示是否向 Eureka 注册中心注册自己 (这个模块本身是服务器,所以不需要)
    register-with-eureka: false
    # fetch-registry 是否拉取其他的服务;如果为 false,则表示自己为注册中心或服务提供者;服务消费者的话为 true
    fetch-registry: false
    # Eureka监控页面~
    service-url:
      defaultZone: http://${
   eureka.instance.hostname}:${
   server.port}/eureka/

在这里插入图片描述

  • register-with-eureka 是否注册到eureka服务中;默认为 true
  • fetch-registry 是否拉取其他的服务;默认为 true
  • 监控地址:http://localhost:7001/
  • 服务注册地址:http://localhost:7001/eureka/

(4)主启动类

@EnableEurekaServer 开启 Eureka 服务端

@SpringBootApplication
@EnableEurekaServer
public class EurekaServer_7001 {
   
    public static void main(String[] args) {
   
        SpringApplication.run(EurekaServer_7001.class,args);
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

土味儿~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值