spring cloud 使用之坑 Request processing failed; nested exception is feign.RetryableException:

    今天使用spring cloud访问其他人暴露的接口,莫名其妙的出现 一次请求成功 一次请求失败的问题,上网找了各种资料,都说是spring cloud zookeper注册的问题,可是我的工程根本没有应用zookper ,这个就尴尬了。


2018-06-08 14:42:20.278 ERROR 3108 --- [nio-8888-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.RetryableException: cannot retry due to redirection, in streaming mode executing POST [图片]http://ucenter/register] with root cause

[图片]java.net.HttpRetryException: cannot retry due to redirection, in streaming mode
	at [图片]sun.net.[图片]www.protocol.http.HttpURLConnection.followRedirect0(HttpURLConnection.java:2637) ~[na:1.8.0_144]
	at [图片]sun.net.[图片]www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2623) ~[na:1.8.0_144]
	at [图片]sun.net.[图片]www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1806) ~[na:1.8.0_144]
	at [图片]sun.net.[图片]www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) ~[na:1.8.0_144]

我的代码如下:




大家不用质疑 我这个接口 我是maven父子工程,接口统一放到common工程里,调用接口的为另外一个子工程。


本次错误主要问题:

注册中心, 有人 同样的工程 不同的端口号 启用了两次服务,导致出现了暴露的接口 出现了同名的情况,并且关闭了其中一个工程, 导致访问的时候出现一次生效,一次失效的问题!!!!!!!

主要解决办法:

 关闭一个相同的工程,实在不行就重启注册中心

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
出现"Request processing failed; nested exception is feign.codec.EncodeException: Error converting request body"错误通常是由于请求体编码错误引起的。请确保您的代码正确配置了编码器,并且文件参数正确传递。 首先,确保您的项目引入了正确的依赖。使用OpenFeign进行文件上传时,需要添加`spring-cloud-starter-openfeign`和`spring-cloud-starter-openfeign`依赖。 如果您使用的是Spring Boot项目,可以在pom.xml文件中添加以下依赖: ```xml <dependencies> <!-- 其他依赖 --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>io.github.openfeign</groupId> <artifactId>feign-form</artifactId> <version>3.10.1</version> </dependency> </dependencies> ``` 接下来,您需要在Feign客户端接口上声明使用`FormEncoder`作为编码器。修改之前的示例代码如下: ```java import feign.Headers; import feign.RequestLine; import feign.codec.Encoder; import feign.form.FormEncoder; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @FeignClient(name = "fileUploadClient", url = "http://example.com", configuration = FileUploadClient.MultipartSupportConfig.class) public interface FileUploadClient { @PostMapping(value = "/upload", consumes = "multipart/form-data") void uploadFile(MultipartFile file); class MultipartSupportConfig { public Encoder feignFormEncoder() { return new FormEncoder(); } } } ``` 在上面的代码中,我们通过在`FileUploadClient`接口上添加`configuration`属性,并在内部类`MultipartSupportConfig`中配置`FormEncoder`来使用正确的编码器。 请确保按照您的项目需求适配上述代码,并引入正确的依赖。这样,您应该能够成功进行文件上传。 如果问题仍然存在,请提供更多的错误信息或代码片段,以便我们能够更好地帮助您解决问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值