码迷,mamicode.com
首页 > 其他好文 > 详细

eureka server 配置

时间:2021-03-01 13:32:05      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:需要   oid   其它   odi   location   oar   server   registry   server1   

启动类

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
 
 

eureka server 配置

标签:需要   oid   其它   odi   location   oar   server   registry   server1   

原文地址:https://www.cnblogs.com/yuyyg/p/14458240.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!