SpringCloud Eureka服务注册中心搭建及问题总结

(1)创建SpringBoot工程,命名eureka-server
(2)pom文件引入依赖
   org.springframework.cloud
   spring-cloud-starter-eureka-server
(3)启动类添加@EnableEurekaServer注解
(4)application.properties文件添加配置
//服务端口
server.port=8761
//应用名称
spring.application.name=eureka-server
//实例名称
eureka.instance.hostname=localhost
//是否向注册中心注册自己
eureka.client.register-with-eureka=false
//是否需要检索服务
eureka.client.fetch-registry=false
//eureka注册中心请求地址
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
//关闭eureka自我保护
eureka.server.enable-self-preservation=false
//eureka服务清理间隔(单位毫秒)
eureka.server.eviction-interval-timer-in-ms=4000
(5)启动EurekaServerApplication类
(6)访问 http://localhost:8761/
(7)看到Spring Eureka 注册页面,如图
SpringCloud Eureka服务注册中心搭建及问题总结_第1张图片
注:
Instances currently registered with Eureka显示 No instances available是因为还没有服务注册到eureka注册中心

eureka服务注册中心搭建遇到问题及解决办法:
1.注册中心搭建完成后,访问 http://localhost:8761/显示Writable error page(即404错误):
解决办法:
尝试一:SpringBoot与SpringCloud版本对应
SpringCloud Eureka服务注册中心搭建及问题总结_第2张图片
SpringCloud版本演进:
SpringCloud Eureka服务注册中心搭建及问题总结_第3张图片

尝试二:
换maven仓库(maven仓库用的是之前的maven仓库,导致maven仓库中的jar包混乱)

你可能感兴趣的:(spring,SpringCloud,SpringBoot,Eureka,maven)