在springboot启动类中注入bean
/** * 设置文件上传大小 * @return */ @Bean public MultipartConfigElement multipartConfigElement() { MultipartConfigFactory factory = new MultipartConfigFactory(); //单个文件最大 factory.setMaxFileSize(DataSize.ofMegabytes(5)); //MB //factory.setMaxFileSize(DataSize.ofKilobytes(80)); //KB //factory.setMaxFileSize(DataSize.ofGigabytes(80)); //Gb /// 设置总上传数据总大小 factory.setMaxRequestSize(DataSize.ofMegabytes(50)); return factory.createMultipartConfig(); }