Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Spring cloud (3): the Construction of Eureka Service

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. Concept: Eureka-Cloud Service Discovery, a REST-based service for locating services to enable cloud middle-tier service discovery and failover.

2. Build: a. First of all, let's talk about building a stand-alone machine. Create a new maven project, and import the coordinates of eureka in pom:

Org.springframework.boot

Spring-boot-starter-parent

1.4.0.RELEASE

Org.springframework.cloud

Spring-cloud-starter-eureka-server

B. Create a new class EurekaApplication

@ SpringBootApplication

@ EnableEurekaServer

Public class EurekaApplication {

Public static void main (String [] args) {

SpringApplication.run (EurekaApplication.class, args)

}

}

Among them, @ EnableEurekaServer starts a service registry to provide dialogue to other applications.

C, configuration items of application.properties

# default port server.port=8761

Eureka.client.register-with-eureka=false

Eureka.client.fetch-registry=false

Eureka.client.serviceUrl.defaultZone= http://localhost:${server.port}/eureka/

D. Start springboot and visit http://localhost:8761/

3. The above is only a stand-alone environment, and the commercial environment is often a highly available (HA) environment. At this time, we have to consider the cluster. One node is dead, and there is another node. We just need to change the configuration file for the cluster.

Eureka.client.serviceUrl.defaultZone= http://localhost:8762/eureka/;http://localhost:8763/eureka/; if the ip is different and three nodes are configured, three machines are required

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report