启动类

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
 
 

最新文章

  1. C# 操作office知识点汇总
  2. Daily Scrum02 12.09
  3. awk 反过滤不想要的列 和循环列
  4. iOS开发 字符串添加行间距
  5. JavaScript基于对象编程
  6. Quickhit快速击键
  7. 【BZOJ】【2729】【HNOI2012】排队
  8. C# 指针(unsafe与fixed的使用)
  9. 使用数据库绑定ListBox控件
  10. OpenCV探索之路(十六):图像矫正技术深入探讨
  11. JavaScript看书笔记01
  12. git在windows及linux环境下安装及常用命令
  13. 解决git冲突造成的Please move or remove them before you can merge
  14. company_credit
  15. python自动化开发-[第十八天]-django的ORM补充与ajax,分页器
  16. Configure the Stanford segmenter for NLTK
  17. 用python写个简单的小程序,编译成exe跑在win10上
  18. Codeforces 242 E. XOR on Segment
  19. ios开发之--NSNumber的使用
  20. datatable 转excel

热门文章

  1. 【noi 2.6_162】Post Office(DP)
  2. hdu2818 Building Block
  3. 已处理证书链,但是在不受信任提供程序信任的根证书中终止 - Windows 7安装.Net Framework 4.6.2时出现此问题
  4. 踏上Revit二次开发之路 1 准备工作
  5. .NET 5学习笔记(10)——Entity Framework Core之切换SQLServer和SQLite
  6. Git 初始化及仓库创建及操作
  7. spark mllib als 参数
  8. IGS OPC UA 配置
  9. spring-cloud-eureka-client-consumer
  10. Vue &amp; Sentry sourcemaps All In One