eureka server 配置
2024-09-07 17:20:15
启动类
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);
}
}
application.yml 配置
server:
port: 8761
spring:
application:
name: eureka_server #集群搭建时建议名称一样
#eureka 一共有四部分配置
#dashboard eureka的web控制台
#service eureka服务端配置
#client eureka客户端配置
#instsance
eureka:
instance:
hostname: localhost #主机名
client:
service-url:
# eureka 服务地址,如果是集群的话;需要指定其它集群eureka地址
default-zone: http://${eureka.instance.hostname}:${server.port}/erueka
# 是否将自己的路径注册到eureka false不注册自己
register-with-eureka: false
#不拉取服务
fetch-registry: false
server:
enable-self-preservation: false
eviction-interval-timer-in-ms: 3000
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring_cloud_parent</artifactId>
<groupId>com.yuyy</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eureka_server</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
</dependencies>
</project>
eureka client/微服务 application.yml 配置
server:
port: 8003
spring:
application:
name: eureka-provider
eureka:
instance:
hostname: localhost
# prefer-ip-address: true #将当前的实例IP注册到 eureka service中,默认是false 注册主机名
# ip-address: 127.0.0.1 #设置当前实例 的IP
# instance-id: ${eureka.instance.ip-address}:${spring.application.name}:${server.port} #设置web显示的实例id
lease-renewal-interval-in-seconds: 3 #每个3秒发送一次心跳包
lease-expiration-duration-in-seconds: 9 #如果9秒没有发送,服务器就把服务干掉
client:
service-url:
# default-zone: http://eureka_server1:8761/eureka,http://eureka_server2:8762/eureka
default-zone: http://localhost:8761/eureka
最新文章
- C# 操作office知识点汇总
- Daily Scrum02 12.09
- awk 反过滤不想要的列 和循环列
- iOS开发 字符串添加行间距
- JavaScript基于对象编程
- Quickhit快速击键
- 【BZOJ】【2729】【HNOI2012】排队
- C# 指针(unsafe与fixed的使用)
- 使用数据库绑定ListBox控件
- OpenCV探索之路(十六):图像矫正技术深入探讨
- JavaScript看书笔记01
- git在windows及linux环境下安装及常用命令
- 解决git冲突造成的Please move or remove them before you can merge
- company_credit
- python自动化开发-[第十八天]-django的ORM补充与ajax,分页器
- Configure the Stanford segmenter for NLTK
- 用python写个简单的小程序,编译成exe跑在win10上
- Codeforces 242 E. XOR on Segment
- ios开发之--NSNumber的使用
- datatable 转excel
热门文章
- 【noi 2.6_162】Post Office(DP)
- hdu2818 Building Block
- 已处理证书链,但是在不受信任提供程序信任的根证书中终止 - Windows 7安装.Net Framework 4.6.2时出现此问题
- 踏上Revit二次开发之路 1 准备工作
- .NET 5学习笔记(10)——Entity Framework Core之切换SQLServer和SQLite
- Git 初始化及仓库创建及操作
- spark mllib als 参数
- IGS OPC UA 配置
- spring-cloud-eureka-client-consumer
- Vue &; Sentry sourcemaps All In One