Spring Cloud——Eureka服务注册
(本文只作为学习记录)
- 新建Spring Boot项目,pom.xml 添加 spring-cloud-starter-eureka 依赖
(parent节点中的版本建议小于2.0.0.RELEASE,本文使用1.5.9.RELEASE)
- application.properties文件添加以下属性
# 应用程序端口
server.port=9001
# 应用程序名字
spring.application.name=hello
# 注册的地址
eureka.client.serviceUrl.defaultZone=http://localhost:9000/eureka/
Tip:
当然,我们 前文 体到的Eureka服务注册中心可以是多个并且相互注册成集群服务,这样在某一个因为故障不能使用时不会导致系统的崩溃。此处不详细说明,有兴趣的同学可以自行了解一下。