解决办法:
Api 接口
@Api(tags = "文件上接口")
@RestController
public class FileController {@Autowiredprivate FileFeignService fileFeignService;@ApiOperation("上传文件")@PostMapping(value = "/uploadFile")public ResData<String> uploadFile(@RequestParam("file") MultipartFile file) {String url = fileFeignService.uploadFile(file);return ResData.ok(url);}}
openfeign
@FeignClient("file-server")
public interface FileFeignService {@PostMapping(value = "file/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)String uploadFile(@RequestPart("file") MultipartFile file);}
文件服务
@RestController
@RequestMapping("/file")
public class FileController {@Autowiredprivate OssServer ossServer;@PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)public String uploadFile(@RequestPart("file") MultipartFile file) {return ossServer.uploadFile(file);}}