问题:在使用MultipartFile类型上传文件时,发现上传的文件过大会报异常,异常信息如下:
org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (51071023) exceeds the configured maximum (10485760)
问题解决:出现这个问题是因为上传的文件大小超过了默认最大大小,可以使用修改默认大小来解决这个问题
在application.properties
文件中,配置接收文件的大小
#设置接收文件大小spring.servlet.multipart.enabled=truespring.servlet.multipart.max-file-size=931775308spring.servlet.multipart.max-request-size=1000MB
配置好后,重新启动项目进行文件上传,发现大的文件也可以正常上传了