Spring Cloud Feign(报错1)

使用Feign组件进行远程服务的调用的时候,报错信息如下

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.example.eurekaclient1.feign.UserFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: PathVariable annotation was empty on param 0.

Caused by: java.lang.IllegalStateException: PathVariable annotation was empty on param 0.

Feign接口中的代码如下:

@FeignClient(value = "eureka-client1")
public interface UserFeignClient {
@RequestMapping("/test/findById/{id}")
public User findById(@PathVariable int id);
}

修改之后不报错

@FeignClient(value = "eureka-client1")
public interface UserFeignClient {
@RequestMapping("/test/findById/{id}")
public User findById(@PathVariable(value = "id") int id);
}

记录:Feign组件进行HTTP调用的时候,如果路径中有@PathVariable,则需指明param。

posted @ 2020-05-23 04:06  wuyiping  阅读(276)  评论(0编辑  收藏  举报