当前位置:  开发笔记 > 程序员 > 正文

弹簧安全启动弹簧websocket失败,"没有bean命名'stompWebSocketHandlerMapping'被定义'

如何解决《弹簧安全启动弹簧websocket失败,"没有bean命名'stompWebSocketHandlerMapping'被定义'》经验,为你挑选了1个好方法。

spring boot version 1.3.0发布.

错误日志是

13:00:50.888 [main]错误osboot.SpringApplication - 应用程序启动失败org.springframework.beans.factory.NoSuchBeanDefinitionException:org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory)中未定义名为'stompWebSocketHandlerMapping'的bean .java:698)〜[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1175)~ [spring- bean-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] 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]在org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigurer.afterSingletonsInstantiated(AbstractSecurityWebSocketMessageBrokerConfigurer.java:222)〜[spring-security-config-4.0.3.RELEASE.jar:4.0.3 .RELEASE]在org.springframework.context的org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792)〜[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE] .support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)〜[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java: 537)〜[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE] org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)~ [spring-boot-1.3 or.0.RELEASE.jar:1.3.0.RELEASE]在org.springframework.boot.Spri 在org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347)〜[spring]的ngApplication.refresh(SpringApplication.java:752)〜[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE] -boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]在org.springframework.boot.SpringApplication.run(SpringApplication.java:295)〜[spring-boot-1.3.0.RELEASE.jar:1.3. 0.RELEASE]在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();
    }
}

Artem Bilan.. 5

WebSocket Security用于STOMP子协议,并依赖于STOMP Broker Configuration.

您必须将您更改@EnableWebSocket@EnableWebSocketMessageBroker并继续进行AbstractSecurityWebSocketMessageBrokerConfigurer配置.

WebSocketConfigurer顺便说一下,你不需要那种情况.



1> Artem Bilan..:

WebSocket Security用于STOMP子协议,并依赖于STOMP Broker Configuration.

您必须将您更改@EnableWebSocket@EnableWebSocketMessageBroker并继续进行AbstractSecurityWebSocketMessageBrokerConfigurer配置.

WebSocketConfigurer顺便说一下,你不需要那种情况.

推荐阅读
有风吹过best
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有