搭建Eureka注册中心

搭建Eureka服务中心#

(1) 创建shop_eureka_server子模块#

在 shop_parent 下创建子模块 shop_eureka_server

(2) 引入maven坐标#

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

(3) 配置application.yml#

复制代码
server:
 port: 8761
eureka:
 instance:
   hostname: localhost
 client:
   registerWithEureka: false  
   fetchRegistry: false
   serviceUrl:
     defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
复制代码
registerWithEureka: 是否将自己注册到Eureka服务中,本身就是所有无需注册
fetchRegistry : 是否从Eureka中获取注册信息
serviceUrlEureka: 客户端与Eureka服务端进行交互的地址

(4) 配置启动类#

在 com.yyj.eureka 下创建启动类 EurekaServerApplication
复制代码
package com.yyj.eureka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}
View Code
复制代码
EnableEurekaServer : 激活Eureka Server端配置
服务注册中心管理后台
打开浏览器访问http://localhost:8761即可进入EurekaServer内置的管理控制台,显示效果如下:
 
posted @   1640808365  阅读(60)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示
主题色彩