关于websocket的介绍网上一搜一大把,这里还是简单啰嗦一句:WebSocket 是 HTML5 开始提供的一种在单个 TCP 连接上进行全双工通讯的协议。
个人理解,websocket的最明显的特点就是:可以由后台服务主动向前端推送消息,从而避免了前端轮询造成的资源浪费
环境
- jdk1.8
- idea2018.3
- gradle4.10.3
- springboot2
依赖
compile group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '2.0.1'
compile group: 'org.yeauty', name: 'netty-websocket-spring-boot-starter', version: '0.6.3'
compile ("org.springframework.boot:spring-boot-starter:2.1.6.RELEASE")
compile ("org.springframework.boot:spring-boot-starter-web:2.1.6.RELEASE")
compile 'org.apache.httpcomponents:httpclient:4.4.1'
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.58'
compile ('mysql:mysql-connec