springboot消息推送框架
时间: 2023-09-04 09:16:55 浏览: 119
SpringBoot消息推送框架可以使用WebSocket来实现。要使用WebSocket推送消息, 首先需要在pom文件中添加所需的jar包依赖。具体步骤如下:首先,在pom文件中添加以下依赖:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- 处理数据用 跟推送无关 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>
```
然后,创建一个配置文件(最好放在根目录下)WebSocketConfig.java,代码如下:
```java
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter(){
return new ServerEndpointExporter();
}
}
```
这样就完成了SpringBoot集成WebSocket的配置。你可以根据实际需求,利用WebSocket来实现消息推送功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [springboot框架下的实时消息推送](https://blog.csdn.net/qq_39731741/article/details/90520105)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Springboot集成MyBatisplus并且实现自动生成代码模板](https://download.csdn.net/download/qq_33417321/88237864)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文