@FeignClient 接口上不允许使用 @RequestMapping 注解
我遇到了麻烦!正如我一直在阅读的那样,这种情况的发生是因为它不再被接受。但我该如何解决呢? 这是我一直在尝试映射的代码。
@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);
}
预先感谢您的任何建议或解决方案!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用@FeignClient的
path
属性来定义要添加到所有API的路径前缀。该文档是 此处。所以你的 Feign 客户端界面看起来像
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