首页 > 编程语言 > 详细

创建spring boot集成webSocket前后端消息发送的实现

时间:2020-08-10 17:09:28      阅读:95      评论:0      收藏:0      [点我收藏+]

整体功能说明

前后台可以对多个webSocket进行数据变更的传播。支持心跳

1.创建项目

技术分享图片

 

 

2.新建web目录

新建web目录存放前端静态文件

技术分享图片

 

3.注入依赖

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.3.1.RELEASE</version>
        </dependency>
        <!--websocket连接需要使用到的包-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
            <version>2.3.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.3.1.RELEASE</version>
            <scope>test</scope>
        </dependency>

静态文件打包(红字)

    <build>
        <resources>
            <resource>
                <directory>src/main/web</directory>
                <targetPath>META-INF/resources</targetPath>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

 

4.整体项目结构

技术分享图片

 

创建spring boot集成webSocket前后端消息发送的实现

原文:https://www.cnblogs.com/linhongwenBlog/p/13469996.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!