WebSockets
Spring Boot 为嵌入式 Tomcat、Jetty 和 Undertow 提供了 WebSockets 自动配置。如果您将 war 文件部署到独立容器,Spring Boot 会假定该容器负责其 WebSocket 支持的配置。
Spring Framework 为 MVC Web 应用提供了丰富的 WebSocket 支持,可以通过 spring-boot-starter-websocket
模块轻松访问。
WebSocket 支持也适用于响应式 Web 应用,需要 alongside spring-boot-starter-webflux
并包含 WebSocket API。
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
</dependency>