SpringCloud study notes ---- Euraka registry

First, create a project SpringCloud

Create a common maven project SpringcloudDemo. Then add springcloud in pom.xml file, springboot dependence

Note: springcloud and springboot version to match, otherwise easily lead to project start unsuccessful.

Refer to the official version corresponding to the particular network: https://start.spring.io/actuator/info

Here springcloud corresponding springboot relevant version, there are other versions of the corresponding specific information may refer to the above official website information.

Two, Eureka registry

MicroService the most crucial and most basic component is the registry. Below implement the service registry using the Spring Cloud Eureka. And register a simple service provider.

Creating EurekaServer sub-module maven project created above and add eureka-server dependencies.

Create a startup class, add annotations to enable @EnableEurekaServer registry service at startup class. Application.properties modify the configuration file:

Then start the project browser to access localhost: 8809.

The interface description appears on Eureka registry now created.

Next, create EurekaClient client.

Three, EurekaClient client

Here create two EurekaClient (EurekaClient1, EurekaClient2), the specific role of the follow-up will show.

Creating EurekaClient1, EurekaClient2 two sub-modules, then add the client dependent. (Client-dependent two are the same, the specific configuration can view the configuration of demo)

Then modify the configuration file application.properties

Add @ EnableEurekaClient on the client startup class, @ EnableDiscoveryClient said it was the EurekaClient.

The difference between two notes of reference: https://blog.csdn.net/boling_cavalry/article/details/82668480

Started two projects, then localhost: 8809 you can see the registered clients come in two friends.

So far, Eureka registration center is set up to complete it.

ps: for the first time to write, I do not know how to write. I hope you can understand. There are improvements can leave a comment below. Thank you!

SpringCloudDemo: https://download.csdn.net/download/sklaaaa/12233091 (resources may review, please try again later)

Disclaimer: This article is a blogger original article, reproduced, please attach the original source link and this statement.

Released four original articles · won praise 0 · Views 127

Guess you like

Origin blog.csdn.net/sklaaaa/article/details/104712394