None of the configuration above worked for me with a Spring application.
Implementing this code in the main application class (the one annotated with @SpringBootApplication) did the trick.
@Bean
EmbeddedServletContainerCustomizer containerCustomizer() throws Exception {
return (ConfigurableEmbeddedServletContainer container) -> {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(
(connector) -> {
connector.setMaxPostSize(10000000);//10MB
}
);
}
};
}
You can change the accepted size in the statement:
connector.setMaxPostSize(10000000);//10MB