spring cloud Enreka服务治理

服务治理是微服务架构最为核心和基础的模块,主要用来实现各个微服务实例的自动化注册和发现。

记录一下服务注册中心的搭建以及高可用注册中心的实现

1.首先创建两个基础 的spring boot工程,spring boot创建工程的网站:,创建界面如下

spring cloud Enreka服务治理

2.解压工程,用Maven的形式导入工程(File->new->project from Existing Soures,选择解压工程导入)

3.两个工程中都添加依赖(eureka)

1 <properties> 2 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 3 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 4 <java.version>1.8</java.version> 5 <spring-cloud.version>Finchley.RELEASE</spring-cloud.version> 6 </properties> 7 8 <dependencies> 9 <dependency> 10 <groupId>org.springframework.boot</groupId> 11 <artifactId>spring-boot-starter-web</artifactId> 12 </dependency> 13 <dependency> 14 <groupId>org.springframework.cloud</groupId> 15 <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> 16 </dependency> 17 18 <dependency> 19 <groupId>org.springframework.boot</groupId> 20 <artifactId>spring-boot-starter-test</artifactId> 21 <scope>test</scope> 22 </dependency> 23 </dependencies> 24 25 <dependencyManagement> 26 <dependencies> 27 <dependency> 28 <groupId>org.springframework.cloud</groupId> 29 <artifactId>spring-cloud-dependencies</artifactId> 30 <version>${spring-cloud.version}</version> 31 <type>pom</type> 32 <scope>import</scope> 33 </dependency> 34 </dependencies> 35 </dependencyManagement> 36 37 <build> 38 <plugins> 39 <plugin> 40 <groupId>org.springframework.boot</groupId> 41 <artifactId>spring-boot-maven-plugin</artifactId> 42 </plugin> 43 </plugins> 44 </build>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zywyyd.html