SpringBoot限制文件上传大小 The field file exceeds its maximum permitted size of 1048576 bytes

spring boot 项目 默认上传文件大小为 1Mb 所以上传大文件 就会如下错误

rdContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 10485760 bytes.
	at org.apache.catalina.connector.Request.parseParts(Request.java:2947)
	at org.apache.catalina.connector.Request.parseParameters(Request.java:3242)
	at org.apache.catalina.connector.Request.getParameter(Request.java:1136)
	at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:381)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:84)
	... 23 more
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException: The field file exceeds its maximum permitted size of 10485760 bytes.
	at org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl$FileItemStreamImpl$1.raiseError(FileUploadBase.java:628)
	at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.checkLimit(LimitedInputStream.java:76)
	at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:135)
	at java.io.FilterInputStream.read(FilterInputStream.java:107)
	at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:98)
	at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:68)
	at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:293)
	at org.apache.catalina.connector.Request.parseParts(Request.java:2902)
	... 27 more

SpringBoot 2.0配置文件大小:

spring.servlet.multipart.max-file-size=10Mb  单个文件限制

spring.servlet.multipart.max-request-size=100Mb 请求总文件大小限制

SpringBooSpringBoot1.5.9版本

spring.http.multipart.maxFileSize=10Mb

spring.http.multipart.maxRequestSize=100M

你可能感兴趣的:(springboot)