Spring Cloud——Eureka服务注册中心
(本文只作为学习记录)
创建一个Spring Boot项目,引入 Spring-cloud-starter-eureka-server 依赖
(parent节点中的版本建议小于2.0.0.RELEASE,本文使用1.5.9.RELEASE)
启动类添加
@EnableEurekaServer
注解application.preperties文件添加以下属性禁止eureka注册自己
# 应用程序端口
server.port=9000
# 应用程序域名
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/
- 打开浏览器访问
http://localhost:9000/