Eureka注册中心的使用

发布时间 2023-06-09 23:54:20作者: kd最棒
  • 简单介绍:

Eureka能够自动注册并发现微服务,然后对服务的状态、信息进行集中管理,这样当我们需要获取其他服务的信息时,我们只需要向Eureka进行查询就可以了。

image

  • 首先在工程中搭建一个Eureka服务器

只需要创建一个新的Maven项目即可

image

需要父工程有SpringCloud依赖,如果没有添加依赖.
例:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>2021.0.1</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
  • 为新创建的项目添加 Eureka 依赖:
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>
</dependencies>

参考:
https://blog.csdn.net/qq_25928447/article/details/123748607?spm=1001.2014.3001.5502