Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to edit the default maxPostSize of embedded Tomcat in SpringBoot
@Bean
EmbeddedServletContainerCustomizer containerCustomizer(
) throws Exception {
return (ConfigurableEmbeddedServletContainer container) -> {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(
(connector) -> {
connector.setMaxPostSize(10000000);//10MB
}
);
}
};
}
@dalesupa22

This comment has been minimized.

Copy link
Owner Author

commented Jun 9, 2015

This is very useful because the default config in SpringBoot only allows to upload 2 MB files.

@dalesupa22

This comment has been minimized.

Copy link
Owner Author

commented Jun 9, 2015

org.apache.catalina.connector.Request.class line 2779 if (postSize > maxPostSize) {
throw new IllegalStateException(sm.getString(
"coyoteRequest.maxPostSizeExceeded"));
}

@dalesupa22

This comment has been minimized.

Copy link
Owner Author

commented Jun 9, 2015

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

@prashanth-g

This comment has been minimized.

Copy link

commented Sep 8, 2015

Thanks buddy 👍 Really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.