spring cloud实战 1-高可用注册中心
Posted lijianming180
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring cloud实战 1-高可用注册中心相关的知识,希望对你有一定的参考价值。
创建父maven项目
提交代码至GitHub
创建eureka-server-1
项目搭建两种方式:
- 父pom中继承spring-boot-starter-parent,子pom中直接结成父pom。该方式比较方便,但子项目都是spring boot项目了。
- 父项目不需要继承spring-boot-starter-parent,子pom中通过使用scope = import依赖关系。
1 | <dependencyManagement> |
参考文档 http://tengj.top/2017/02/26/springboot1/
EurekaServer1Application中声明@EnableEurekaServer
创建eureka-server-2
- 修改hosts文件,C:WINDOWSsystem32driversetchosts,新增
127.0.0.1 eureka1 eureka2 - 修改application.yml文件,如下为eureka2中的部分配置,eureka1修改同理。
1 | spring: |
- 将服务注册到高可用eureka中心,修改如下即可。
1 | eureka: |
eureka-server
高可用注册中心在本项目中用不到,所以另外创建一个eureka-server,之后的项目均注册到此
复制eureka-server-1修改一下即可。
以上是关于spring cloud实战 1-高可用注册中心的主要内容,如果未能解决你的问题,请参考以下文章
Spring Cloud Eureka 4 (高可用服务注册中心)
基于Spring Cloud的微服务构建学习-3 服务治理-Spring Cloud Eureka之高可用注册中心