Spring Boot Tomcat配置,从容器迁移到嵌入式 [英] Spring Boot Tomcat Configuration, migration from container to embedded
本文介绍了Spring Boot Tomcat配置,从容器迁移到嵌入式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将以前在Tomcat容器中运行的Spring启动应用程序迁移到运行嵌入式Tomcat的Spring Boot应用程序。
我的旧Tomcat配置在server.xml中有这些配置:
I'm migrating a Spring boot application that used to run in the Tomcat container to a Spring Boot application that runs an embedded Tomcat. My old Tomcat configuration has these configurations in the 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设置大部分属性
I was able to set up most of the properties using a 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属性:
And application.xml properties:
server.tomcat.accept-count = 500
server.tomcat.max-threads = 600
server.port = 8080
server.max-http-header-size = 32768
server.connection-timeout = 20000
但是我无法弄清楚如何设置这个部分
However I cannot figure out how to set this part
useComet="false"
socket.appReadBufSize="87380"
socket.rxBufSize="87380"
socket.performanceConnectionTime="2"
socket.performanceLatency="0"
socket.performanceBandwidth="1"
server="My server"
任何人都可以帮助我吗?
谢谢
Can anyone help me please? Thank you
推荐答案
试试这个:
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");
这篇关于Spring Boot Tomcat配置,从容器迁移到嵌入式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文