作者:最棒小小丫_635 | 来源:互联网 | 2023-02-05 18:16
我有这样的FeignClient
@RequestLine("POST /enroll")
@Headers({ "header1: {header1}", "header2: {header2}", "Content-Type: application/json" })
ResponseDto enroll(@Param("header1") String header1,@Param("header1") String header1, RequestDto requestDto)throws MyCustomException;
`我没有使用spring cloud netflix.但我一直得到以下例外.
Caused by: java.lang.IllegalStateException: Body parameters cannot be used with form parameters.
at feign.Util.checkState(Util.java:128)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:112)
at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:64)
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:146)
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:53)
at feign.Feign$Builder.target(Feign.java:209)
at feign.Feign$Builder.target(Feign.java:205)
我像这样实例化我的客户端.
return Feign.builder()
.encoder(new JacksonEncoder())
.decoder(new JacksonDecoder())
.logger(new Slf4jLogger())
.logLevel(Logger.Level.FULL)
.target(RegularFeignClient.class, url);
Seetharamani..
12
哇这是一个棘手的问题.参数的顺序在这里很重要.
@RequestLine("POST /enroll")
@Headers({ "header1: {header1}", "header2: {header2}", "Content-Type: application/json" })
ResponseDto enroll(RequestDto requestDto, @Param("header1") String header1,@Param("header1") String header1)throws MyCustomException;
这个工作!!!
感谢我的高级开发人员.他找到了.
1> Seetharamani..:
哇这是一个棘手的问题.参数的顺序在这里很重要.
@RequestLine("POST /enroll")
@Headers({ "header1: {header1}", "header2: {header2}", "Content-Type: application/json" })
ResponseDto enroll(RequestDto requestDto, @Param("header1") String header1,@Param("header1") String header1)throws MyCustomException;
这个工作!!!
感谢我的高级开发人员.他找到了.