My Springboot application used TomcatEmbeddedServletContainerFactory to upload large(2GB) file,now tomcat dependency we are not using, but currently using jetty dependency. So using JettyEmbeddedServletContainerFactory need to set the file limit-> setMaxSwallowSize(-1) in SpringBoot Application.class.
@SpringBootApplication
@ServletComponentScan
@ComponentScan({ "com.abc" })
@EnableAspectJAutoProxy
@EnableScheduling
@EnableAsync
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean public TomcatEmbeddedServletContainerFactory tomcatEmbedded() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { if
((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) {
//-1 means unlimited ((AbstractHttp11Protocol<?>)
connector.getProtocolHandler()).setMaxSwallowSize(-1); } });
}
}
Any one can u please help with using JettyEmbeddedServletContainerFactory in SpringBoot Application.class
@SpringBootApplication
@ServletComponentScan
@ComponentScan({ "com.abc" })
@EnableAspectJAutoProxy
@EnableScheduling
@EnableAsync
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public JettyEmbeddedServletContainerFactory servletContainer() {
JettyEmbeddedServletContainerFactory factory1 = new JettyEmbeddedServletContainerFactory(); // JettyServerCustomizer
factory1.setMaxSwallowSize(-1);
return factory1;
}
}