Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 带弹簧安全启动的弹簧websocket失败,错误为;没有名为'的bean;stompWebSocketHandlerMapping&x27;定义为';_Spring_Spring Security_Spring Boot_Spring Websocket - Fatal编程技术网

Spring 带弹簧安全启动的弹簧websocket失败,错误为;没有名为'的bean;stompWebSocketHandlerMapping&x27;定义为';

Spring 带弹簧安全启动的弹簧websocket失败,错误为;没有名为'的bean;stompWebSocketHandlerMapping&x27;定义为';,spring,spring-security,spring-boot,spring-websocket,Spring,Spring Security,Spring Boot,Spring Websocket,spring boot版本1.3.0发行版 错误日志是 13:00:50.888[主]错误o.s.boot.SpringApplication-应用程序 启动失败 org.springframework.beans.factory.noSuchBean定义异常:否 名为“stompWebSocketHandlerMapping”的bean在上定义 org.springframework.beans.factory.support.DefaultListableBeanFactory.getBea

spring boot版本1.3.0发行版

错误日志是

13:00:50.888[主]错误o.s.boot.SpringApplication-应用程序 启动失败 org.springframework.beans.factory.noSuchBean定义异常:否 名为“stompWebSocketHandlerMapping”的bean在上定义 org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:698) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1175) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1057) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigure.AfterSingleTons实例化(AbstractSecurityWebSocketMessageBrokerConfigure.java:222) ~[spring-security-config-4.0.3.RELEASE.jar:4.0.3.RELEASE] org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:792) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]at com.d2js.platform.manager.Main.Main(Main.java:28)[classes/:na]

我的websocket配置类

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Autowired
    private final TeacherMonitorHandler teacherMonitorHandler = null;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(teacherMonitorHandler, "/websocket/teacherMonitor");
    }
}
websocket安全配置类:

@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
    @Override
    protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {
        messages.anyMessage().permitAll();
    }
}

WebSocket安全性用于STOMP子协议,并依赖于STOMP代理配置

您必须将
@EnableWebSocket
更改为
@EnableWebSocketMessageBroker
,然后继续执行
AbstractSecurityWebsocketMessageBrokerConfigure
配置

顺便说一下,在这种情况下,您不需要
WebSocketConfigurer