gpt4 book ai didi

java - Spring Boot Tomcat配置,从容器迁移到嵌入式

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:24:40 24 4
gpt4 key购买 nike

我正在将过去在 Tomcat 容器中运行的 Spring Boot 应用程序迁移到运行嵌入式 Tomcat 的 Spring Boot 应用程序。我的旧 Tomcat 配置在 server.xml 中有这些配置:

<Connector 
executor="tomcatThreadPool"
port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
acceptCount="500"
acceptorThreadCount="2"
maxThreads="150"
maxHttpHeaderSize="32768"
maxHeaderCount="256"
connectionTimeout="20000"
maxKeepAliveRequests="-1"
redirectPort="8443"
useComet="false"
socket.appReadBufSize="87380"
socket.rxBufSize="87380"
socket.performanceConnectionTime="2"
socket.performanceLatency="0"
socket.performanceBandwidth="1"
server="My server"
/>

我能够使用 bean 设置大部分属性

@Bean
public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = new TomcatEmbeddedServletContainerFactory();
tomcatEmbeddedServletContainerFactory.setProtocol("org.apache.coyote.http11.Http11Nio2Protocol");
tomcatEmbeddedServletContainerFactory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
AbstractHttp11JsseProtocol<Nio2Channel> handler = (AbstractHttp11JsseProtocol)connector.getProtocolHandler();
handler.setMaxKeepAliveRequests(-1);
handler.setAcceptorThreadCount(2);
handler.setMaxHeaderCount(256);
connector.setRedirectPort(8443);
});

return tomcatEmbeddedServletContainerFactory;
}

和 application.xml 属性:

server.tomcat.accept-count = 500
server.tomcat.max-threads = 600
server.port = 8080
server.max-http-header-size = 32768
server.connection-timeout = 20000

但是我不知道如何设置这部分

useComet="false"
socket.appReadBufSize="87380"
socket.rxBufSize="87380"
socket.performanceConnectionTime="2"
socket.performanceLatency="0"
socket.performanceBandwidth="1"
server="My server"

谁能帮帮我?谢谢

最佳答案

试试这个:

connector.setProperty("useComet", Boolean.toString(false));
connector.setProperty("socket.appReadBufSize", "87380");
connector.setProperty("socket.rxBufSize", "87380");
connector.setProperty("socket.performanceConnectionTime", "2");
connector.setProperty("socket.performanceLatency", "0");
connector.setProperty("socket.performanceBandwidth", "1");
connector.setProperty("server", "My server");

关于java - Spring Boot Tomcat配置,从容器迁移到嵌入式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44791514/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com