搭建注册中心Eureka
2020-02-28 本文已影响0人
piziyang12138
-
idea创建Eureka Server
1.File->new->project->spring initializer->select dependencies Eureka Server->下一步 创建



2.application.yml
###服务端口号
server:
port: 8000
###eureka 基本信息配置
eureka:
instance:
###注册到eurekaip地址
hostname: 127.0.0.1
client:
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
###因为自己是为注册中心,不需要自己注册自己
register-with-eureka: false
###因为自己是为注册中心,不需要检索服务
fetch-registry: false
server:
# 测试时关闭自我保护机制,保证不可用服务及时踢出
enable-self-preservation: false
eviction-interval-timer-in-ms: 2000
3.启动Eureka服务
@EnableEurekaServer
@SpringBootApplication
public class AppEureka {
public static void main(String[] args) {
SpringApplication.run(AppEureka.class, args);
}
}
#@EnableEurekaServer作用:开启eurekaServer

5.Eureka服务搭建完成