目录
- 代码示例
- 注意点:
- 2021.3.16更新:发新的坑
- 部分异常及解决方案
-
- 异常一:[Method has too many Body parameters](https://blog.csdn.net/haishiyizhenfeng/article/details/80607003)
- 异常二:[@FeignClient注入找不到的异常](https://blog.csdn.net/qq_28165595/article/details/102328066)
- 异常三:[feign.FeignException$MethodNotAllowed: status 405](https://blog.csdn.net/qq_43371556/article/details/100548389)
- 其他问题
代码示例
/**
* 用于上传文传
* UploadFile包含fileName、fileDesc
* 不加@RequestParam等同于@RequestParam(required = false)
*
* @param file 文件
* @param entity 文件的描述
* @return
*/
@PostMapping("/add")
public Response<Object> add(
@RequestPart(value = "file") MultipartFile file,
UploadFile entity,
) {
Response<Object> res = new Response<>();
FileHandlerResult handlerResult = service.saveFile(file);
return res;
}
@FeignClient(value = "file-server")
public interface FileService {
@PostMapping(value = "/static/add", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Response<LinkedHashMap<Object, Object>> saveFile(