在 Spring Boot 嵌入式 Tomcat 中配置 maxKeepAliveRequests [英] Configuring maxKeepAliveRequests in Spring Boot embedded Tomcat
问题描述
我需要将 Spring Boot Zuul 网关中的 maxKeepAliveRequests 值修改为高于默认值 100 的值.注意该值未在 Spring Boot 的 常用属性列表,我尝试通过@Configuration类设置属性:
I need to modify the maxKeepAliveRequests value in my Spring Boot Zuul gateway to a value higher than the default 100. Noting that this value is not exposed in Spring Boot's common properties list, I tried to set the property via @Configuration class instead:
@Configuration
public class DefaultConfig {
@Bean
public EmbeddedServletContainerFactory servletContainerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addConnectorCustomizers(connector ->
((AbstractHttp11Protocol) connector.getProtocolHandler()).setMaxKeepAliveRequests(1000));
return factory;
}
}
但似乎并没有达到预期的效果.是否有适当的方法可以更改未通过 Spring 公共属性公开的 Tomcat 属性?
But it doesn't seem to take the desired effect. Is there a proper way for me to change Tomcat properties that are not exposed via Spring common properties?
推荐答案
以上代码已经确认可以工作.错误的@ComponentScan 范围导致我的代码无法工作,这是一个愚蠢的错误.
The code above has been confirmed to work. It was a silly mistake with a wrong @ComponentScan scope that caused my code not to work.
这篇关于在 Spring Boot 嵌入式 Tomcat 中配置 maxKeepAliveRequests的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!