Created
June 9, 2015 14:14
-
-
Save dalesupa22/2b5f67afd7a8b3a39714 to your computer and use it in GitHub Desktop.
How to edit the default maxPostSize of embedded Tomcat in SpringBoot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
EmbeddedServletContainerCustomizer containerCustomizer( | |
) throws Exception { | |
return (ConfigurableEmbeddedServletContainer container) -> { | |
if (container instanceof TomcatEmbeddedServletContainerFactory) { | |
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; | |
tomcat.addConnectorCustomizers( | |
(connector) -> { | |
connector.setMaxPostSize(10000000);//10MB | |
} | |
); | |
} | |
}; | |
} |
org.apache.catalina.connector.Request.class line 2779 if (postSize > maxPostSize) {
throw new IllegalStateException(sm.getString(
"coyoteRequest.maxPostSizeExceeded"));
}
This solves the following exception: Caused by: java.lang.IllegalStateException: The multi-part request contained parameter data (excluding uploaded files) that exceeded the limit for maxPostSize set on the associated connector
Thanks buddy 👍 Really helpful
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very useful because the default config in SpringBoot only allows to upload 2 MB files.