Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does Java Spring Cloud create a service registry

Shulou Source: shulou.com Published: 2022-06-01 07:07:49 11月11日 Update

This article introduces the knowledge of "how to create a service registry in Java Spring Cloud". Many people will encounter this dilemma in the operation of practical cases. Let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Service registry: we will use service discovery and service registration, which is done with a single-node Eureka Server.

Two micro services: account service and customer service. Each microservice has its own database and exposes a simple responsive API for retrieving and storing data. In addition, customer service and account service can communicate with each other to get all of the customer's accounts and return them through the customer service API method.

Database: because few databases have available drivers for reactive data access, Spring Data Reactive currently supports only MangoDB, Redis, and Cassandra, so we use MangoDB for simplicity. I use Docker to create MangoDB here, and everything uses the default configuration (mainly lazy, so there is no need to change the Spring Boot configuration file)

Docker run-d-name mongo-p 27017 mongo operational Services Registration Centre

Create a new basic Spring Boot project, named eureka-server.

The dependent coordinates in pom.xml are as follows:

Org.springframework.cloud spring-cloud-starter-netflix-eureka-server

The configuration file application.yml is configured as follows:

Spring: application: name: eureka-servereureka: client: register-with-eureka: false fetch-registry: false service-url: defaultZone: http://localhost:8000/eureka/server: port: 8000

Add @ EnableEurekaServer annotation to the startup class

@ EnableEurekaServer@SpringBootApplicationpublic class EurekaServerApplication {public static void main (String [] args) {SpringApplication.run (EurekaServerApplication.class, args);}} "how Java Spring Cloud creates a service registry" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Service data customer configuration customer service account database content file more knowledge utility learning next no two reactive dilemma coordinates actual combat Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi Huawei MariaDB Shulou Technology