项目中用到websocket,就将原来写好的websocket工具类直接拿来使用,发现前端建立连接的时候报404,经查找发现是因为原来用的是配置的外部tomcat启动,这次是spring boot自带的启动,查找看网上说要加入以下配置:

1,添加依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>

2,添加配置

@Configuration
public class WebSocketConfig { @Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
} }

3,添加注解@Component

@ServerEndpoint(value = "/socket/{userId}")
@Component
public class SocketServer{}

结果启动报错:

Error creating bean with name 'serverEndpointedExporter' defined in class path resource

Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available

查了半天发现按照网上的方法改了都没有用,后同事提示说看看依赖是否有冲突,经过检查发现确是因为依赖冲突了,解决了冲突之后成功启动,可以和前端建立连接

spring boot整合websocket之使用自带tomcat启动项目报错记录的更多相关文章

  1. Spring Boot 添加jersey-mvc-freemarker依赖后内置tomcat启动不了解决方案

    我在我的Spring Boot 项目的pom.xml中添加了jersey-mvc-freemarker依赖后,内置tomcat启动不了. 报错信息如下: org.springframework.con ...

  2. spring boot整合websocket

    转载自:https://www.cnblogs.com/GoodHelper/p/7078381.html 一.WebSocket简单介绍 随着互联网的发展,传统的HTTP协议已经很难满足Web应用日 ...

  3. spring boot整合WebSocket示例

    1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 2.GITHUB地址 https://github.com/nbfujx/springBo ...

  4. spring boot 当参数传入开头多个0时,报错:JSON parse error: Invalid numeric value: Leading zeroes not allowed

    原因是: Jackson解析json配置的问题 在配置文件中设置下: spring.jackson.parser.allow-numeric-leading-zeros=true

  5. spring boot使用jpa查询mysql数据库的视图时不报错,但查询结果数据总是重复第一条

    问题描述: 在数据库里查询到的结果是正常显示的 在程序中返回的结果: 解决方法: 添加行号作为主键: 解决! 我明明是前端啊前端,为啥在搞后台....,总感觉我要在向全栈进发,希望自己有朝一日真的能成 ...

  6. spring boot 2.0 thymeleaf调试时正常,打包后运行报错. 找不到模板文件.

    使用th:fragment  定义模板 使用 th:replace  来添加模板到需要的地方. 使用时发现一个非常奇怪的问题. 本机idea 调试环境一切正常, 但是打成jar包以后报错,提示找不到对 ...

  7. spring boot集成shiro-redis时,分布式根据seesionId获取session报错排查总结

    昨天在集成shiro-redis的时候,使用sessionId在其他微服务获取用户的session时,发生错误:There is no session with id [xxx]. 查遍了所有资料,基 ...

  8. idea 启动项目报错,more than one fragment with the name [spring web] was found

    这是由于idea导入项目的时候有多个模块,并且有多个web.xml导致的,先删除对应的模块,后启动即可. 另外也有可能是spring的jar冲突,把冲突的jar删除即可.

  9. 解决Electron加载带jquery的项目报错问题

    <!-- Insert this line above script imports --> <script>if (typeof module === 'object') { ...

随机推荐

  1. arm树莓派Raspbian 下安装selenium+chrome

    arm树莓派Raspbian 下安装selenium+chrome 安装selenium pip3 install selenium 安装chromedriver sudo apt-get insta ...

  2. 【转载】如何删除Windows远程桌面保存的账号密码数据

    在Windows系统中,无论是win7.win8还是win10系统,都可使用Windows系统自带的远程桌面连接工具来远程服务器,很多时候Windows远程桌面在连接一次后会自动保存连接的账号密码等信 ...

  3. angular创建一个独立弹窗服务

    1.说明: 这个服务用于创建一个modal(弹窗),通常下,这个弹窗会插入到body的底部,并且拥有自己的作用域($scope),也可以和外界通讯. 2.逻辑: (1).创建模版 (2).拿到模版里要 ...

  4. 安全SECUERITY英文SECUERITY证券

    security Alternative forms secuerity (mostly obsolete) English Alternative forms secuerity Pronuncia ...

  5. Vue组件开发分享

    在开始本文之前,你可能需要先了解以下相关内容: Vue.js  一款高性能轻量化的MVVM框架 Webpack  前端模块化代码构建工具 Vue组件介绍 基于vue.js高效的双向数据绑定特性,让我们 ...

  6. 你与BAT只差这一套面试题

    1.Linux如何挂载windows下的共享目录?mount.cifs //IP地址/server /mnt/server -o user=administrator,password=123456l ...

  7. mysqldump 备份

    1.  直接备份某个库或表 ,或多个库多个表mysqldump -uroot -pPassword [database name] > [dump file]mysqldump -uroot - ...

  8. 常用内置模块(二)--logging、hashlib、shelve、xml、configparser

    一.logging模块 1.logging作用 1. 控制日志级别  2. 控制日志格式  3. 控制输出的目标为文件 2.日志级别 1 logging.debug( 2 logging.info( ...

  9. H3C 802.1x认证接入过程

  10. linux下activemq安装与配置activemq-5.15.2

    linux下activemq安装与配置 前提 配置好jdk环境   一.下载:apache-activemq-5.15.2-bin.tar.gz https://archive.apache.org/ ...