org.springframework.beans.factory.UnsatisfiedDependencyException 等 get或post 调用时 Feign远程调用异常

224 阅读1分钟

目录

报错信息  找caused by 后面的信息

关键位置: ->  

发现类似问题:  

 正确写法: 


报错信息  找caused by 后面的信息

这个一直往后面翻 看到最后一个进行反推

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'feignConsumerController': Unsatisfied dependency expressed through field 'remoteProviderService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.jt.consumer.service.RemoteProviderService': 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.
at feign.Util.checkState(Util.java:129) ~[feign-core-10.10.1.jar:na]
at org.springframework.cloud.openfeign.annotation.PathVariableParameterProcessor.processArgument(PathVariableParameterProcessor.java:52) ~[spring-cloud-openfeign-core-2.2.6.RELEASE.jar:2.2.6.RELEASE]
at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:304) ~[spring-cloud-openfeign-core-2.2.6.RELEASE.jar:2.2.6.RELEASE]

发现类似问题:  

 

 正确写法: 

 String echo(@PathVariable("msg") String msg);

问题二:  注意 远程调用post请求时候

不能使用参数拼接  需要使用@RequestBody的json格式进行传递,  否则值传递不过来

消费者需要加@RequestBody   服务者依旧需要添加