【Eureka】服务注册到eureka / eureka-client 配置

EUREKA客户端怎样配置

相关版本

springboot 版本:2.1.17 (貌似 springboot1.x 和 2.x 有一点区别)

步骤

1、添加依赖

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

2、启动类添加注解

import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@EnableEurekaClient
public class MyApplication {
// balabala 启动类
}

3、配置中心/配置文件 添加 eureka-client 信息

eureka:
client:
registryFetchIntervalSeconds: 5
instanceInfoReplicationIntervalSeconds: 5
initialInstanceInfoReplicationIntervalSeconds: 5
serviceUrl:
defaultZone: http://@localhost:8761/eureka/
#defaultZone: http://username:password@localhost:8761/eureka/ (如果设置了账号密码,就用这种写法)

至此,eureka-client 端的配置就基本完成了。。。

posted @   aaacarrot  阅读(35)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示