> For the complete documentation index, see [llms.txt](https://doc.shiker.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.shiker.tech/spring-boot-can-kao-wen-dang/10.-xiao-xi/10.7.-websockets.md).

# 10.7. WebSockets

Spring Boot 为嵌入式 Tomcat、Jetty 和 Undertow 提供 WebSockets 自动配置。如果将 war 文件部署到独立容器，Spring Boot 会假定该容器负责配置其 WebSocket 支持。

Spring框架为MVC Web应用程序提供了[丰富的WebSocket支持](https://docs.spring.io/spring-framework/reference/6.1/web/websocket.html)，可以通过`spring-boot-starter-websocket`模块轻松访问。

WebSocket 支持也可用于[反应式 Web 应用程序](https://docs.spring.io/spring-framework/reference/6.1/web/webflux-websocket.html)，并且需要同时包含属于`spring-boot-starter-webflux`的 WebSocket API ：

```
<dependency>
    <groupId>jakarta.websocket</groupId>
    <artifactId>jakarta.websocket-api</artifactId>
</dependency>
```
