|
此版本仍在开发中,尚未被视为稳定版本。如需最新稳定版本,请使用 Spring Boot 4.0.4! |
WebSockets
Spring Boot 为嵌入式的 Tomcat、Jetty 和 Undertow 提供了 WebSocket 的自动配置。 如果你将 war 文件部署到独立的容器中,Spring Boot 会假设该容器负责其 WebSocket 支持的配置。
Spring Framework 为 MVC 网络应用程序提供了丰富的 WebSocket 支持,可以通过 spring-boot-starter-websocket 模块轻松访问。
WebSocket 支持也适用于 响应式 Web 应用程序,并且需要包含 WebSocket API 以及 spring-boot-starter-webflux:
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
</dependency>