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

Spring Boot About 1,181 words

错误信息

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

}
Views: 2,329 · Posted: 2022-09-19

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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


Today On History
Browsing Refresh