irpas技术客

Application run failedorg.springframework.beans.factory.UnsatisfiedDependencyExc

irpas 3455

? ? ? ? 将服务注册到 eureka 中,使用 feign 远程调用服务,服务消费者调用服务提供者,出现的以下错误,

一、报错信息

UnsatisfiedDependencyException:不满足依赖异常

SpringApplication - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException:

Error creating bean with name 'courseController':

Unsatisfied dependency expressed through field 'cmsPageClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.yh.manage.course.feign.CmsPageClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: PathVariable annotation was empty on param 0.

Caused by: org.springframework.beans.factory.BeanCreationException:

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

二、错误原因

? ? ? ? 1.源代码? ---> 报错代码

@FeignClient(value = "yh-service-manage-cms") // 指定feign远程要调用的服务 public interface CmsPageClient { // 创建方法 @GetMapping("/cms/page/get/{id}") // 指定路径,源服务方法上的路径 public CmsPageResult findCmsPageId(@PathVariable String id); }

? ? ? ? 2.错误原因,是找不到 @PathVariable 指定的 参数id??

? ? ? ? 修改方法 --->? (@PathVariable(value = "id") String id);重新指定下参数即可

? ? ? ? 此报错有的电脑运行环境并不会出现这个错误,


1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。

标签: #Application #run #将服务注册到 #Eureka #中使用 #Feign