文件上传 Feign

59 阅读1分钟

1 增加配置类 `package com.szlanyou.busicen.certification.center.otherservice;

import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Scope;

import feign.codec.Encoder; import feign.form.spring.SpringFormEncoder;

/**

  • feign配置类 */ @Configuration public class FeignSupportConfig { @Bean @Primary @Scope("prototype") public Encoder multipartFormEncoder() { return new SpringFormEncoder(); }

    @Bean public feign.Logger.Level multipartLoggerLevel() { return feign.Logger.Level.FULL; } } 2 FeignClient增加配置 @FeignClient(configuration = FeignSupportConfig.class) 3produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = MediaType.MULTIPART_FORM_DATA_VALUE 4 @RequestPart(name = "uploadfile") MultipartFile uploadfile` OK.............................