eureka single machine of spring cloud

1. Briefly, what is eureka

Eureka is a Netflix open source product that provides service registration and discovery. It provides a complete implementation of Service Registry and Service Discovery. It is also one of the most important and core components in the spring cloud system.

I simply understand it as the registration center. All services must be registered in the registry, and all call paths are obtained in the registry

2. Start eureka

(1) Project initialization

Establish a eureka project from scratch, and you can directly access the official initialization platform of spring , it can also be generated by using the spring initializr plug-in on idea, and the steps are the same.

After writing the name of your project and selecting the spring boot and Java version, select the add dependencies required by the project. You can directly search eureka in the plug-in. You can select it directly in the category and check it to confirm.

The following is the operation steps on idea: right click on the project = "new =" module = "Spring initializr", and then next. The following interface appears to modify the pointed contents

Then select the dependency next (as shown in the figure below). The last way is next finish.

(2) Project overview

After the above operations, you can get an item after initialization

Important pom files are as follows (if there is an initialized spring boot project, it is also possible to directly add relevant pom dependencies)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""
    <description>Registration Center</description>


Other documents will be modified later. See below.

(3) Modify yml configuration file

The YML file (application.yml, renamed from is as follows

    enable-self-preservation: false  #Turn off self-protection mechanism
    eviction-interval-timer-in-ms: 4000 #Set the cleaning interval (unit: ms, default: 60 * 1000)
    hostname: eureka
    registerWithEureka: false #Don't register yourself as a client
    fetchRegistry: false  #You don't need to get the registration information from the server (because you are the server here, and your registration has been disabled)
      defaultZone: http://Localhost: the address of ${server. Port} / Eureka / #eureka server. The deployment address is written for a single machine

(4) Add startup class annotation

Add the annotation @ EnableEurekaServer ( on the startup class

The basic configuration of such a stand-alone registration center is good

(5) Start effect

Access after local startup http://localhost:3000 The effect is as follows

Such a registration center is completed;

(6) Supplement (service provider and service consumer)

Here, a stand-alone registration center has been built, but it is not sure whether the functions of this registration center are available; Therefore, if you need to verify whether the function is complete, you also need to have service providers and service consumers jointly test the registration and discovery function of the registry.

Keywords: Spring Cloud eureka

Added by Dtonlinegames on Wed, 09 Feb 2022 22:07:16 +0200