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