我一直在尝试设置一个简单的 WebSocketHandler 实现,但我遇到了这个javax.servlet.ServletException: No adapter for handler [turnip.gg.TurnipWebSocketHandler@5fdceca2]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
我无法解决的错误。
这是我的配置;
@Configuration
class WebSocket {
@Autowired
@Qualifier("TurnipWebSocket")
private lateinit var handler: WebSocketHandler
@Bean
fun handlerMapping() = SimpleUrlHandlerMapping(mapOf("/socket" to handler), 1)
@Bean
fun handlerAdapter() = WebSocketHandlerAdapter()
}
这是我的简单 WebSocketHandler
@Component("TurnipWebSocket")
class TurnipWebSocketHandler : WebSocketHandler {
override fun handle(session: WebSocketSession): Mono<Void> = session.receive()... // Does other stuff with it
}
提前致谢!