You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何判断Spring Boot应用是否使用NIO?默认配置疑问

问题

我们在Spring Boot 2.0.3项目的所有源码文件中未搜索到NIO相关提及。根据Spring官方文档,NIO默认是禁用的,因此我们认为应用未使用NIO。但应用启动时日志显示“restartedMain org.apache.coyote.http11.Http11NioProtocol [] => Initializing ProtocolHandler ["http-nio-8080"]”,请问这是否意味着我们正在使用NIO?若确实如此,是否说明官方文档的默认配置描述有误?

启动日志详情:

2024-10-23T09:10:56,001Z INFO  restartedMain o.s.b.web.embedded.tomcat.TomcatWebServer [] => Tomcat initialized with port(s): 8080 (http)
2024-10-23T09:10:56,031Z INFO  restartedMain org.apache.coyote.http11.Http11NioProtocol [] => Initializing ProtocolHandler ["http-nio-8080"]
2024-10-23T09:10:56,052Z INFO  restartedMain org.apache.catalina.core.StandardService [] => Starting service [Tomcat]
2024-10-23T09:10:56,052Z INFO  restartedMain org.apache.catalina.core.StandardEngine [] => Starting Servlet Engine: Apache Tomcat/8.5.31
解答
  • 确实在使用NIO:日志中的Http11NioProtocol明确表明,你的应用正在通过嵌入式Tomcat使用NIO作为HTTP协议处理方式,这是Spring Boot 2.x版本中嵌入式Tomcat的默认配置。
  • 官方文档描述无错误:你参考的是Spring Integration模块的IP端点配置文档,和Spring Boot嵌入式Tomcat的默认协议配置分属不同模块。Spring Integration的NIO端点(如TCP/UDP的NIO适配器)默认禁用,但Spring Boot本身对嵌入式Tomcat的默认配置就是启用NIO协议,二者不存在冲突。

内容的提问来源于stack exchange,提问作者John Little

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 02:18:14