Springboot下websocket报错

在学习websocket,想在现有项目中使用websocket,我通过pom文件引入如下

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

但是项目启动后,报错如下

Caused by: java.io.FileNotFoundException: class path resource [org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurer.class] cannot be opened because it does not exist

使用websocket的地方如下

package project.unicom.office.hall.admin.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class MyWebsocketConfig implements WebSocketMessageBrokerConfigurer {
    //
}

我分析是pom依赖冲突,如下图,在pom文件中排除了omitted for duplicate的项目可还是报上面的错,我的这个项目是使用tomcat war包的,现在不知道如何解决了,请高人指点。
image.png

阅读 4.9k
1 个回答

mvn clean compile 应该就可以了,没有重新编译

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题