Solve the problem of failure to upload large files in springboot

I recently received an error when sending a file exceeding 1M via the web:

org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 1048576 bytes

Or report the following error

[dispatcherservlet] throw java io ioexception  stream close

Solution:

1.spring boot 1.x version

spring.http.multipart.maxFileSize = 10Mb

spring.http.multipart.maxRequestSize=100Mb

2.spring boot 2.x version

spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=100MB

After configuration, just restart the system 


 

Guess you like

Origin blog.csdn.net/f746262041/article/details/127992393