Project: spring boot + mybatis plus + spring + redis
Test interface
@ApiOperation (value = "Single file upload test interface" ) @PostMapping (value = "/ file" ) public String fileUpload (MultipartFile file) { if (file.getSize ()> 0 ) { System.out.println ( "Upload Success " ); } return " " ; }
The swagger or postman test found that the file parameter cannot receive the file and is always null.
solution:
<!-- <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>1.3.2</version> </dependency>--> <!-- <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.2</version> </dependency>-->
/*@Configuration public class MultipartResolverConfig { @Bean(name = "multipartResolver") public MultipartResolver multipartResolver(){ CommonsMultipartResolver resolver = new CommonsMultipartResolver(); //上传文件大小 10M 10*1024*1024 resolver.setMaxUploadSize(10*1024*1024); resolver.setDefaultEncoding("UTF-8"); return resolver; } }*/
End