EUREKA Service Configuration (Registration Center)

Description: According to the Restful distributed architecture in the previous article, a basic design architecture has been implemented based on Rest at this time. For the program design in the previous article, the SpringBoot client is directly used to directly access the SpringCloud server. At this time, you need to know the host address of the server clearly before you can call the microservice, but what happens if the host address changes? If we use the mode of the previous article, we need to manually modify all microservice host addresses. This is too expensive to maintain, so we need to introduce a registry, that is, all microservices register with the registry, and then the client obtains it according to the registry Information about microservices. So we need to use Eureka. Once the project wants to introduce Eureka, it means that our project needs to be managed by SpringCloud, that is, we must now introduce SpringCloud dependencies into the project.

1. [micro] Reference SpringCloud dependency library in the parent project:

 < dependency>
                org.springframework.cloud
                spring-cloud-dependencies
                Dalston.SR5
                pom
                import
             
//The current project has successfully introduced SpringCloud dependencies, and then SpringCloud can be used to manage all Rest microservices.

Eureka service construction: If you want to use Eureka in a project, you only need to introduce the corresponding dependency library, and establish the corresponding project to start directly.

2. [micro-eureka-7001] The introduction of Eureka requires the introduction of corresponding dependent libraries:

 
            org.springframework.cloud
            spring-cloud-starter-eureka-server
        

3. [micro-eureka-7001] Modify the program startup class and add an Eureka startup comment:

 
                org.springframework.cloud
                spring-cloud-dependencies
                Dalston.SR5
                pom
                import
             
//The current project has successfully introduced SpringCloud dependencies, and then SpringCloud can be used to manage all Rest microservices.

 
            org.springframework.cloud
            spring-cloud-starter-eureka-server
        

Leave a Comment

Your email address will not be published.