Spring Cloud Feign(报错1)
Posted wuyiping
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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。
以上是关于Spring Cloud Feign(报错1)的主要内容,如果未能解决你的问题,请参考以下文章
spring cloud feign 报错 feign.FeignException$MethodNotAllowed: status 405 reading
spring-cloud-feign 使用@RequetParam报错QueryMap parameter must be a Map: class java.lang.String
Spring Cloud Feign - 报错:Method has too many Body parameters 说明 #解决方法
Bug集锦-Spring Cloud Feign调用其它接口报错