在学习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包的,现在不知道如何解决了,请高人指点。
mvn clean compile 应该就可以了,没有重新编译