拓冰建站拓冰建站
首页 / 资讯中心 / 正文

关于OpenFeign使用的一些小知识

1.Feign 实际发送的请求路径 http://服务名/Feign 接口路径FeignClient(value report-service, path /reportApi) public interface ReportFeignClient { GetMapping(/getTerOnlineData) String getData(); }服务名由FeignClient(value 服务名)指定。由服务注册中心Nacos 等自动解析为ip端口。Feign接口的路径path(/reportApi)GetMapping(/getTerOnlineData)→ 完整路径为/reportApi/getTerOnlineData2. Feign 接口的Service接口方法中RequestParam必须指定value值GetMapping(/user) User getUserByAge(RequestParam(value age) Integer userAge); // valueage 对应 URL 中的 ?agexxxPathParam通常需要指定value值GetMapping(/user/{id}) User getUserById(PathParam(value id) String userId); // valueid 对应路径中的 {id} 占位符
分享:

看完干货,该让你的企业上线了

免费需求沟通 · 48 小时内出具建站方案 · 河南本地可上门