From a058cc139e90b14be581fad48c2e79772b5ae637 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Sun, 29 Mar 2015 00:44:01 +0800 Subject: [PATCH] Update 64.16. Create WebSocket endpoints using @ServerEndpoint.md --- ...16. Create WebSocket endpoints using @ServerEndpoint.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/IX. ‘How-to’ guides/64.16. Create WebSocket endpoints using @ServerEndpoint.md b/IX. ‘How-to’ guides/64.16. Create WebSocket endpoints using @ServerEndpoint.md index e69de29..bed423d 100644 --- a/IX. ‘How-to’ guides/64.16. Create WebSocket endpoints using @ServerEndpoint.md +++ b/IX. ‘How-to’ guides/64.16. Create WebSocket endpoints using @ServerEndpoint.md @@ -0,0 +1,10 @@ +### 64.16. 使用@ServerEndpoint创建WebSocket端点 + +如果想在一个使用内嵌容器的Spring Boot应用中使用@ServerEndpoint,你需要声明一个单独的ServerEndpointExporter @Bean: +```java +@Bean +public ServerEndpointExporter serverEndpointExporter() { + return new ServerEndpointExporter(); +} +``` +该bean将用底层的WebSocket容器注册任何的被`@ServerEndpoint`注解的beans。当部署到一个单独的servlet容器时,该角色将被一个servlet容器初始化方法履行,ServerEndpointExporter bean也就不是必需的了。