Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker DevOps


Spring Boot OpenFeign IllegalStateException: RequestParam.value() was empty on parameter 0

Spring Boot 大约 1181 字

错误信息

Caused by: java.lang.IllegalStateException: RequestParam.value() was empty on parameter 0
    at feign.Util.checkState(Util.java:129)
    at org.springframework.cloud.openfeign.annotation.RequestParamParameterProcessor.processArgument(RequestParamParameterProcessor.java:63)
    at org.springframework.cloud.openfeign.support.SpringMvcContract.processAnnotationsOnParameter(SpringMvcContract.java:274)
    at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:111)
    at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:187)
    at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:62)
    at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:151)
    at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:49)
    at feign.Feign$Builder.target(Feign.java:269)

错误原因

在使用spring-cloud-starter-openfeign@RequestParam注解时没有传入name字段。

解决方法

增加name字段。

@FeignClient(name = "myFeignClient", url = "${test.url}")
public interface MyFeginClient {

    @GetMapping("/test")
    List<String> getInfo(@RequestParam(name = "userId", required = false) String userId);

}
阅读 30 · 发布于 2022-09-19

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批