FileSizeLimitExceededException: The field files exceeds its maximum permitted size of 1048576 bytes

时间:2024-03-26 15:55:03

FileSizeLimitExceededException: The field files exceeds its maximum permitted size of 1048576 bytes.

日常记录遇到得小问题~
FileSizeLimitExceededException: The field files exceeds its maximum permitted size of 1048576 bytes
在springboot项目中上传文件超过1Mb报错,解决办法:在application.yml中增加
servlet:
multipart:
max-file-size: -1
max-request-size: -1
enabled: true
FileSizeLimitExceededException: The field files exceeds its maximum permitted size of 1048576 bytes
其中-1代表不限制大小,也可以配置为1024MB。
springboot2.0和1.4的写法不一致,需要注意。
增加了这个配置之后本地上传是好使得,但是当更新到现网之后仍有报错:
FileSizeLimitExceededException: The field files exceeds its maximum permitted size of 1048576 bytes
解决办法:修改nginx.conf,在http{}中增加client_max_body_size 2000m;
FileSizeLimitExceededException: The field files exceeds its maximum permitted size of 1048576 bytes
然后重启ngnix就可以了~