preface

This article is just a BUG solving record made by the author. The source of each person’s problems may be different, so there is little reference value.

Problem description

GetPaymentById (U_U)O (U_U)O (U_U)O (U_U)O



Project analysis



Feign is naturally used on the client side to call cloud-payment-service services, and it is clear that poM and YML file configuration are not a problem.

There is no problem with the startup file, which specifies the @enableFeignClients annotation to activate Feign and @enableEurekaclient to activate Eureka service registration and service discovery.



And then the Controller layer, that’s where the getPaymentById method is called, and it says it can’t find it, why can’t it find it, is it on the Service layer soon?



Service layer, @feignclient: cloud-payment-service, port 8001,8002,8004 Feign is the same as the Ribbon+RestTemplate for load balancing and service invocation. Feign directly specifies services and methods to be invoked using interface annotations



GetPaymentById: /payment/get/{id}; /get/{id}; So if you call Feign, you won’t find this method 404 NOT FOUND

@RestController
@RequestMapping("/payment")
public class PaymentController {    
    ...  

    @GetMapping("/get/{id}")    
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id) { Payment payment = IPaymentService.getPaymentById(id); .Copy the code

Problem solving

To do so, it’s just a matter of changing the Service layer that was previously used in Feign



Let’s test it out. Successful return data YEAH!