当前位置: 首页 > article >正文

SpringBoot项目启动报错:PathVariable annotation was empty on param 0.

报错信息

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);

}

显式指定路径参数名。


http://www.kler.cn/a/567108.html

相关文章:

  • thinkphp下的Job队列处理
  • C语言多级指针详解 - 通过实例理解一级、二级、三级指针
  • day01_Java基础
  • 请谈谈 Node.js 中的流(Stream)模块,如何使用流进行数据处理?
  • Windows提权之第三方提权(九)
  • uniapp选中日期移动到中间
  • P8682 [蓝桥杯 2019 省 B] 等差数列--sort()
  • 宝塔webhooks与码云实现自动部署
  • 基于ArcGIS Pro、Python、USLE、INVEST模型等多技术融合的生态系统服务构建生态安全格局高阶应用
  • 【产品小白】怎么量化用户体验呢
  • 解锁 Hutool - Captcha:轻松打造图片验证码
  • 陕西省地标-DB61/T 1121-2018 政务服务中心建设和运营规范
  • Scanpy单细胞h5ad数据转化为Seurat对象
  • win11编译pytorchaudio cuda128版本流程
  • 【分库分表】基于mysql+shardingSphere的分库分表技术
  • JDK17安装方法/如何安装JDK17/环境变量配置
  • C++奇迹之旅:C++的单例模式
  • STM32G431RBT6——(2)浅析Cortex-M4内核
  • vivo打造最具影响力Rust赛事,点亮基础软件事业的“蓝河时代”
  • 4.万事开头难—第一个Java程序