OpenFeign @PathVariable需注明参数名称
文章目录
在定义 OpenFeign 的远程接口时,如果是路径拼接作为参数的远程接口,需要在@PathVariable需注明参数名称,不然代码启动时会报错。
正例
@FeignClient(value = ServiceConstants.SYSTEM, fallbackFactory = RemoteFileFallbackFactory.class) public interface RemoteFileService { /** * 使文件生效 * @param id 文件ID * @return 结果 */ @PutMapping("file/enable/{id}") BaseResult<Boolean> enable(@PathVariable("id") Long id); }反例
@FeignClient(value = ServiceConstants.SYSTEM, fallbackFactory = RemoteFileFallbackFactory.class) public interface RemoteFileService { /** * 使文件生效 * @param id 文件ID * @return 结果 */ @PutMapping("file/enable/{id}") BaseResult<Boolean> enable(@PathVariable Long id); }
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论