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扫描下方二维码关注公众号和小程序↓↓↓
Loading...