gpt4 book ai didi

Spring Boot Feign Client 方法参数过多

转载 作者:行者123 更新时间:2023-12-02 08:35:15 25 4
gpt4 key购买 nike

我使用 spring-cloud 的 feignClient,当我的界面中有多个 Beans 参数时,就会出现问题,错误显示如下:

Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract com.wxl.pros.test.web.common.CommonResObject com.wxl.pros.test.web.feign.OrderFeignClient.createOrder(com.wxl.pros.test.services.form.order.CreateOrderForm,com.wxl.pros.test.services.vo.User)
at feign.Util.checkState(Util.java:128)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:114)
at org.springframework.cloud.netflix.feign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:133)
at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:64)
at feign.hystrix.HystrixDelegatingContract.parseAndValidatateMetadata(HystrixDelegatingContract.java:34)
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:146)
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:53)
at feign.Feign$Builder.target(Feign.java:209)
at org.springframework.cloud.netflix.feign.HystrixTargeter.target(HystrixTargeter.java:48)
at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:184)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 27 common frames omitted

这是我的界面方法之一:

@RequestMapping(value="/order/createOrder",method=RequestMethod.POST)
public CommonResObject createOrder(@RequestBody OrderForm orderForm,@RequestBody User user);

最佳答案

如果您有多个参数,其中一个请求正文和多个参数。使用精确注释指定参数类型:

ResponseMessage<String> getCustomInformation((@RequestBody CustomRequest request, @RequestParam("language") String language,
@RequestParam("channel") String channel, @RequestParam("requestId") String requestId

关于Spring Boot Feign Client 方法参数过多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43604734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com