programing

@RequestMapping 주석은 @FeignClient 인터페이스에서 허용되지 않습니다.

iphone6s 2023. 7. 26. 21:41
반응형

@RequestMapping 주석은 @FeignClient 인터페이스에서 허용되지 않습니다.

나 이거 곤란해요!제가 읽어본 바와 같이, 그것은 더 이상 받아들여지지 않기 때문에 일어나는 일입니다.하지만 어떻게 해결할 수 있을까요?이게 제가 지도를 그리려고 했던 코드입니다.

@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);
}

제안이나 해결책을 알려주셔서 미리 감사드립니다!

사용할 수 있습니다.path의 속성.@FeignClient모든 API에 추가할 경로 접두사를 정의합니다.설명서는 여기에 있습니다.

그래서 당신의 Feign 클라이언트 인터페이스는 다음과 같습니다.

@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);
}

언급URL : https://stackoverflow.com/questions/71284214/requestmapping-annotation-not-allowed-on-feignclient-interfaces

반응형