Microservices – Spring Cloud – Eureka – Discovery Service Discovery

How to discover services?

The service is registered with the Eureka cluster. Service discovery calls (http) need to be implemented through RestTemplate and @LoadBalanced.

In the previous note, the order service calls the payment service through estTemplate and @LoadBalanced. It is called by the service name registered in the Eureka cluster.

So how do you discover these services? That is to say, how to know the service name registered in the Eureka cluster

Implemented through DiscoveryClient and @EnableDiscoveryClient annotations

Normally speaking, service discovery should be the business of the service caller. Here the code is written in the PaymentController class for convenience. Just for self-testing

main startup class

@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
public class PaymentMain8002 {
   
    
    

    public 

Je suppose que tu aimes

Origine blog.csdn.net/weixin_43713498/article/details/131317601
conseillé
Classement