学习spring cloud ,些了一个图片上传的服务,直接用postman 请求这个服务,是没有问题的,
但是在web层(comsumer层?)用feign去调用这个服务,就报错了,,
the request was rejected because no multipart boundary was found,,,
原文地址: https://github.com/OpenFeign/feign-form
工程中需要依赖这两个东东
<dependencies> ... <dependency> <groupId>io.github.openfeign.form</groupId> <artifactId>feign-form</artifactId> <version>3.2.2</version> </dependency> <dependency> <groupId>io.github.openfeign.form</groupId> <artifactId>feign-form-spring</artifactId> <version>3.2.2</version> </dependency> ... </dependencies>
@FeignClient(name = "file-upload-service", configuration = FileUploadServiceClient.MultipartSupportConfig.class)
public interface FileUploadServiceClient extends IFileUploadServiceClient {
public class MultipartSupportConfig {
@Autowired
private ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
public Encoder feignFormEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
}
}
@FeignClient(name = "file-upload-service", configuration = FileUploadServiceClient.MultipartSupportConfig.class) public interface FileUploadServiceClient extends IFileUploadServiceClient { public class MultipartSupportConfig { @Bean public Encoder feignFormEncoder() { return new SpringFormEncoder(); } } }