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

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

}

显式指定路径参数名。

相关文章:

  • 20250301在chrome中安装CRX猫抓
  • 计算机视觉|ViT详解:打破视觉与语言界限
  • Ruby 数组(Array)
  • Android中使用Robolectric测试点击事件(不需要手机)
  • 卷积神经网络(Convolutional Neural Network,CNN)详细解释(带示例)
  • MySQL 架构与 SQL 执行全流程解析
  • 数据库基础三(MySQL数据库操作)
  • ubuntu防火墙iptables
  • C大调中的A4=440Hz:音乐、物理与认知的交响
  • kubernetes 部署项目
  • 基于javaweb的SpringBoot在线动漫信息平台系统设计和实现(源码+文档+部署讲解)
  • Hive的内置函数
  • 【算法】图论 —— Floyd算法 python
  • Linux 动静态库和_make_进度条(一)
  • 通俗易懂,什么是cache一致性
  • Leetcode-853. Car Fleet [C++][Java]
  • Autosar RTE配置-Port Update配置及使用-基于ETAS工具
  • P8649 [蓝桥杯 2017 省 B] k 倍区间--前缀和--同余定理【蓝桥杯简单题-必开long long】
  • 基于ssm的校园跑腿管理系统+vue
  • 【练习】【贪心】力扣452. 用最少数量的箭引爆气球
  • 网站建设安全要求/怎么样才能引流客人进店
  • 智慧政务门户网站建设/南宁百度关键词推广
  • 做网站费用多少钱/友情链接属于免费推广吗
  • 在闲鱼可以做网站吗/seo基础理论
  • 做决定的网站/搜索引擎优化的主要工作有
  • 如何在百度上注册自己的网站/软文推广广告