服务注册和发现-Spring Cloud Eureka(一)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shenzhen_zsw/article/details/89421487

目录

服务注册和发现-Spring Cloud Eureka(一)

服务注册和发现

注册中心

创建服务注册中心工程

application.properties

注册中心启动类-EurekaSeverApplication 


服务注册和发现-Spring Cloud Eureka(一)

服务注册和发现


 

说明:

Eureka是一个服务发现组件,基于Rest的服务,包含Server和Client;

注册中心

创建服务注册中心工程

application.properties

server.port=8666
spring.application.name=eureka-server
eureka.instance.hostname=127.0.0.1

#留存的服务实例低于多少比例进入保护模式
eureka.server.renewal-percent-threshold=0.5
#是否开启保护模式
eureka.server.enable-self-preservation=true
#是否注册eureka
eureka.client.register-with-eureka=false
#是否启用获取服务注册信息
eureka.client.fetch-registry=false

#注册和查询都需要依赖该地址,多个以逗号分隔
eureka.client.serviceUrl.defaultZone=http://127.0.0.1:8666/eureka/

说明:配置eureka相关配置

注册中心启动类-EurekaSeverApplication 

package com.mooc.house.eurekaserver;

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

@SpringBootApplication
@EnableEurekaServer
public class EurekaSeverApplication {

	public static void main(String[] args) {
		SpringApplication.run(EurekaSeverApplication.class, args);
	}
}

说明:需要添加@EnableEurekaServer用来启动Eureka;

猜你喜欢

转载自blog.csdn.net/shenzhen_zsw/article/details/89421487
今日推荐