Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@RequestMapping annotation not allowed on @FeignClient interfaces

I'm having trouble with this! As I've been reading, it happens because it's no longer accepted. But how can I solved it? This is the code I've been trying to map.

@FeignClient(name = "product-service")
@RequestMapping("api/products/")
public interface ProductClient {

    @GetMapping("/{id}")
    ResponseEntity<Product> getProduct(@PathVariable("id") Long id);

    @GetMapping("/{id}/stock")
    ResponseEntity<Product> updateStockProduct(@PathVariable("id") Long id,@RequestParam(name = "quantity", required = true) Integer quantity);
}

Thanks in advance for any suggestion or solution!

like image 413
DiegoMG Avatar asked Dec 08 '25 08:12

DiegoMG


1 Answers

You can use the path attribute of @FeignClient to define the path prefix to be added to all the APIs. The documentation is here.

So your Feign client interface would look like

@FeignClient(name = "product-service", path = "/api/products")
public interface ProductClient {

    @GetMapping("/{id}")
    ResponseEntity<Product> getProduct(@PathVariable("id") Long id);

    @GetMapping("/{id}/stock")
    ResponseEntity<Product> updateStockProduct(@PathVariable("id") Long id,@RequestParam(name = "quantity", required = true) Integer quantity);
}
like image 50
Madhu Bhat Avatar answered Dec 11 '25 05:12

Madhu Bhat