SpringBoot微服务之间文件(MutipartFile)传输(Eureka,Feign)踩的坑:ClassNotDfException: feign.Request$Body

在实现SpringBoot微服务间使用MutipartFile传输时遇到ClassNotDfException,错误源于feign.Request$Body。解决方案是仅引入特定jar包,避免与其他包冲突。遇到相同问题的开发者可以尝试文中建议。

今天第一次遇到需要微服务之间传输MutipartFile的业务场景,网上找了一圈发现最终报错:ClassNotDfException: feign.Request$Body解决不了。

具体这样的,网上都差不多:

@Configuration
public class MultipartSupportConfig {
    @Autowired
    private ObjectFactory<HttpMessageConverters> messageConverters;

    @Bean
    public Encoder feignFormEncoder() {
        return new SpringFormEncoder(new SpringEncoder(messageConverters));
    }
}
@FeignClient(name = "xxx", configuration = MultipartSupportConfig.class)
@Component
public interface CoreEurekaClient {

    @PostMapping(value = "/core/file/upload/{serverId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public void uploadFile(@RequestPart MultipartFile file,
                           @PathVariable Integer serverId);

}
@PostMapping("/upload/{serverId}")
@ApiOperation("文件上传接口")
public void uploadFile(@RequestParam MultipartFile file,
                       @PathVariable Integer serverId){

    fileService.uploadFile(file, serverId);
}
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值