SpringBoot项目启动报错:PathVariableannotationwasemptyonparam0.
- 其他
- 2025-09-21 12:24:02

报错信息
SpringBoot项目启动报错:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.obstetric.archive.feignclient.DictServiceClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: PathVariable annotation was empty on param 0.
参数传递错误,没有找到参数。
错误代码 @FeignClient(name = "dict", url = "http://localhost:8184/dict", fallbackFactory = DictServiceClientFallbackFactory.class) public interface DictServiceClient { @PostMapping("/obstetric/{type}/{label}") Integer getValueByTypeAndLabel(@PathVariable String type, @PathVariable String label); }在普通的Controller中可以省略路径参数名,但项目中使用了Feign的远程调用,在注解@PathVariable中若不显示指明参数名,就会报错。
修改代码 @FeignClient(name = "dict", url = "http://localhost:8184/dict", fallbackFactory = DictServiceClientFallbackFactory.class) public interface DictServiceClient { @PostMapping("/obstetric/{type}/{label}") Integer getValueByTypeAndLabel(@PathVariable("type") String type, @PathVariable("label") String label); }显式指定路径参数名。
SpringBoot项目启动报错:PathVariableannotationwasemptyonparam0.由讯客互联其他栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“SpringBoot项目启动报错:PathVariableannotationwasemptyonparam0.”