我正在尝试遵循spring.io 的 websocket 教程。只要每个 java 文件都位于同一个包中(我设法进行端到端的 websocket 通信),一切都会正常工作。
我尝试将类提取GreetingController.java
到WebSocketConfig.java
另一个包中。然后该应用程序将无法再通过 websocket 进行通信。
服务器的控制台表明SimpleBrokerMessageHandler
尚未启动。以下是工作版本和非工作版本的日志:
com.example.tutorial.Application : Starting Application on DESKTOP-SOF4KJM with PID 13408
com.example.tutorial.Application : No active profile set, falling back to default profiles: default
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
o.apache.catalina.core.StandardService : Starting service [Tomcat]
org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24]
o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1485 ms
o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientInboundChannelExecutor'
o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'clientOutboundChannelExecutor'
o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'messageBrokerTaskScheduler'
o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'brokerChannelExecutor'
o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
o.s.m.s.b.SimpleBrokerMessageHandler : Starting...
o.s.m.s.b.SimpleBrokerMessageHandler : BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0
我怎样才能让我的 SpringBoot 应用程序知道另一个包中的这个 websocket 端点,知道 是GreetingController带注释的@Controller并且去WebSocketMessageBrokerConfigurer扩展类是带注释的@Configuration& @EnableWebSocketMessageBroker?
慕哥6287543
相关分类