Sprign Cloud Greenwich版本 feign文件上传

springboot 1.5.1
公司项目升级springboot由1.5.1升级到2.1.2.RELEASE,cloud版本也升级到G版本。突然发现文件上传失效。。。之前解决掉的问题又再次出现
问题收集如下:
1.Feign library does not support Multipart requests
2. The current request is not a multipart request
3. the request was rejected because no multipart boundary was found
如果使用的是sprignboot 2.0、cloud F版本以下,则可以通过
feign文件上传 解决

springboot 2.1.2
升级G版本后,
消费方需要删除掉原来引用的,因为该版本已经适配了feign-form和feign-form-spring,无需再次引入

<dependency>
    <groupId>io.github.openfeign.form</groupId>
     <artifactId>feign-form</artifactId>
     <version>3.3.0</version>
 </dependency>
 <dependency>
     <groupId>io.github.openfeign.form</groupId>
     <artifactId>feign-form-spring</artifactId>
     <version>3.3.0</version>
 </dependency>

消费方增加配置文件:

<dependency>
    <groupId>io.github.openfeign.form</groupId>
     <artifactId>feign-form</artifactId>
     <version>3.3.0</version>
 </dependency>
 <dependency>
     <groupId>io.github.openfeign.form</groupId>
     <artifactId>feign-form-spring</artifactId>
     <version>3.3.0</version>
 </dependency>

服务提供方:
使用@RequestPart接收参数,还需定义consumes
@RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public Result<List<FileBO>> upload(@RequestPart("file") MultipartFile [] multipartFiles ) throws IOException;

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值