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

我正在将用于在Tomcat容器中运行的Spring Boot" title="Spring Boot">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");

以上是 Spring Boot Tomcat配置,从容器迁移到嵌入式 的全部内容, 来源链接: utcz.com/qa/404033.html

回到顶部