post api의 처리되는 데이터 최대 사이즈를 알아보자!!
test tool : Postman
os : centos 7
was : tomcat
먼저 아무런 설정없이 10MB짜리 String데이터를 만든 후 데이터를 전송해봤다.
그 결과 아래와같은 에러가 나왔다.
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (11315105) exceeds the configured maximum (10485760)
에러를 보면 아무것도 설정안했을때 기본 최대 사이즈는 10485760
이라는 걸 알 수 있다.
먼저 spring boot 설정파일을 변경해준다.
아래링크를 참고해서 변경했다.
Increase HTTP Post maxPostSize in Spring Boot
I've got a fairly simple Spring Boot web application, I have a single HTML page with a form with enctype="multipart/form-data". I'm getting this error: The multi-part request contained parameter...
stackoverflow.com
spring boot properties file
spring.servlet.multipart.max-file-size=30MB
spring.servlet.multipart.max-request-size=30MB
spring boot yaml file
spring:
servlet:
multipart:
max-file-size: 30MB
max-request-size: 30MB
오른쪽 값을 -1
로 설정하면 무한으로 설정되는것같다.
설정 후 실행했을때 또 에러가 나온다.
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector
마지막으로 tomcat 디렉토리에서 server.xml
파일 설정을 해준다.
server.xml
에서 connector
태그를 찾아서 maxPostSize
를 설정한다.
...
<Connector port="8080" protocol="HTTP/1.1"
maxPostSize="30000000"
...
Apache Tomcat 8 Configuration Reference (8.5.66) - The HTTP Connector
This Connector supports all of the required features of the HTTP/1.1 protocol, as described in RFCs 7230-7235, including persistent connections, pipelining, expectations and chunked encoding. If the client supports only HTTP/1.0 or HTTP/0.9, the Connector
tomcat.apache.org
tomcat 8.5 문서를 찾아보면 maxPostSize
에대한 설명이 나와있다.
'Error resolution' 카테고리의 다른 글
Spring boot 3 JUnit test java.lang.NoSuchMethodError 'parseQualifiedMethodName' 이슈 해결 (0) | 2023.09.06 |
---|---|
Spring 실행 중 Tibero DB Archive Log Full 처리 (0) | 2021.08.06 |
[Maven] *.jar에 기본 Manifest 속성이 없습니다. 에러 (0) | 2021.05.06 |
[linux 에러] 어플리케이션 too many open files 에러 해결 (0) | 2021.05.06 |
[redis-server] (error) NOAUTH Authentication required 에러 (0) | 2021.04.12 |