首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >对象字符串失败,没有异常。

对象字符串失败,没有异常。
EN

Stack Overflow用户
提问于 2021-11-13 00:50:27
回答 1查看 611关注 0票数 0

我正在使用,并且一直试图将一个对象转换为一个JSON字符串。

如果我在main方法中这样做,它将按预期转换为JSON字符串,但在端点内完成时,它会阻止任何进展,但不会抛出任何异常。

我用的是Corretto 17.0.1。

主要方法

代码语言:javascript
运行
复制
public static void main(String[] args) {
    final ObjectMapper mapper = new ObjectMapper();
    try {
        System.out.println(mapper.writeValueAsString(new Room(0, "Room Name")));
        // Outputs "{"id":0,"name":"Room Name","bluePlayerId":null,"redPlayerId":null,"board":{"blueScore":0,"redScore":0,"bluePiecesInPlay":3,"redPiecesInPlay":3,"state":31,"bluePieces":42,"redPieces":44040192,"allPieces":44040234}}" as expected. 
    } catch (Throwable e) {
        e.printStackTrace();
    }
}

Spring端点

这只是输出“生成”,而不打印任何其他内容。调试时,只需跳过它并完成测试。

代码语言:javascript
运行
复制
@Autowired
private ObjectMapper objectMapper;

@MessageMapping("/welcome/{roomName}")
@SendTo("/topic/greetings")
public String greeting(@DestinationVariable String roomName) {
    System.out.println("Generating");

    try {
        System.out.println(objectMapper.writeValueAsString(new Room(0, "Room Name")));
        System.out.println("Complete");
    } catch (Throwable e) {
        System.out.println("Caught exception");
        e.printStackTrace();
    }
    return "Hello!";
}

Gradle

代码语言:javascript
运行
复制
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web:2.5.6'
    implementation 'org.springframework.boot:spring-boot-starter-websocket:2.5.6'
    testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.6'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
}

日志(跟踪)

代码语言:javascript
运行
复制
Generating
2021-11-13 10:35:07.430 TRACE 9204 --- [    Test worker] o.s.test.context.TestContextManager      : afterTestClass(): class [com.app.cairnserver.controller.RoomControllerTest]
2021-11-13 10:35:07.431 DEBUG 9204 --- [    Test worker] c.DefaultCacheAwareContextLoaderDelegate : Retrieved ApplicationContext [2118984327] from cache with key [[WebMergedContextConfiguration@76ba13c testClass = RoomControllerTest, locations = '{}', classes = '{class com.app.cairnserver.CairnServerApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@33308786, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@561868a0, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@21a21c64, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@531f4093, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3568f9d2, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@1e6454ec], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]]]
2021-11-13 10:35:07.431 DEBUG 9204 --- [    Test worker] org.springframework.test.context.cache   : Spring test ApplicationContext cache statistics: [DefaultContextCache@197ce367 size = 1, maxSize = 32, parentContextCount = 0, hitCount = 11, missCount = 1]
2021-11-13 10:35:07.432 DEBUG 9204 --- [    Test worker] tractDirtiesContextTestExecutionListener : After test class: context [DefaultTestContext@274872f8 testClass = RoomControllerTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@76ba13c testClass = RoomControllerTest, locations = '{}', classes = '{class com.app.cairnserver.CairnServerApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=0}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@33308786, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@561868a0, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@21a21c64, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@531f4093, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3568f9d2, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@1e6454ec], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> false, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]], class annotated with @DirtiesContext [false] with mode [null].
2021-11-13 10:35:07.440 DEBUG 9204 --- [ionShutdownHook] o.s.b.a.ApplicationAvailabilityBean      : Application availability state ReadinessState changed from ACCEPTING_TRAFFIC to REFUSING_TRAFFIC
2021-11-13 10:35:07.440 DEBUG 9204 --- [ionShutdownHook] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7e4d2287, started on Sat Nov 13 10:35:03 GMT 2021
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'stompWebSocketHandlerMapping'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'subProtocolWebSocketHandler'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'simpAnnotationMethodMessageHandler'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'simpleBrokerMessageHandler'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'stompBrokerRelayMessageHandler'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'userDestinationMessageHandler'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'lifecycleProcessor'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'webServerGracefulShutdown'
2021-11-13 10:35:07.441 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'webServerStartStop'
2021-11-13 10:35:07.441 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483647
2021-11-13 10:35:07.442 TRACE 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Asking bean 'stompWebSocketHandlerMapping' of type [org.springframework.web.socket.server.support.WebSocketHandlerMapping] to stop
2021-11-13 10:35:07.442 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Bean 'stompWebSocketHandlerMapping' completed its stop procedure
2021-11-13 10:35:07.442 TRACE 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Asking bean 'subProtocolWebSocketHandler' of type [org.springframework.web.socket.messaging.SubProtocolWebSocketHandler] to stop
2021-11-13 10:35:07.442 DEBUG 9204 --- [ionShutdownHook] o.s.m.s.ExecutorSubscribableChannel      : clientOutboundChannel removed SubProtocolWebSocketHandler[StompSubProtocolHandler[v10.stomp, v11.stomp, v12.stomp]]
2021-11-13 10:35:07.442 DEBUG 9204 --- [ionShutdownHook] s.w.s.s.t.s.WebSocketServerSockJsSession : Closing SockJS session de878120ded742a78ba92f16b12ba9e1 with CloseStatus[code=1001, reason=null]
2021-11-13 10:35:07.442 TRACE 9204 --- [ionShutdownHook] s.w.s.s.t.s.WebSocketServerSockJsSession : Writing SockJsFrame content='c[1001,""]'
2021-11-13 10:35:07.442 TRACE 9204 --- [ionShutdownHook] o.s.w.s.adapter.NativeWebSocketSession   : Sending TextMessage payload=[c[1001,""]], byteCount=10, last=true], StandardWebSocketSession[id=31cd4a31-05d6-9c7e-cd3a-6653dfe98f53, uri=ws://localhost:57909/chess-websocket/433/de878120ded742a78ba92f16b12ba9e1/websocket]
2021-11-13 10:35:07.443 TRACE 9204 --- [ionShutdownHook] s.w.s.s.t.s.WebSocketServerSockJsSession : Cancelling heartbeat in session de878120ded742a78ba92f16b12ba9e1
2021-11-13 10:35:07.443 DEBUG 9204 --- [ionShutdownHook] o.s.w.s.adapter.NativeWebSocketSession   : Closing StandardWebSocketSession[id=31cd4a31-05d6-9c7e-cd3a-6653dfe98f53, uri=ws://localhost:57909/chess-websocket/433/de878120ded742a78ba92f16b12ba9e1/websocket]
2021-11-13 10:35:07.443 DEBUG 9204 --- [lient-AsyncIO-8] o.s.w.s.s.c.WebSocketClientSockJsSession : Processing SockJS close frame with CloseStatus[code=1001, reason=] in WebSocketClientSockJsSession[id='de878120ded742a78ba92f16b12ba9e1, url=ws://localhost:57909/chess-websocket]
2021-11-13 10:35:07.443 DEBUG 9204 --- [lient-AsyncIO-8] o.s.w.s.adapter.NativeWebSocketSession   : Closing StandardWebSocketSession[id=2b84c8e4-9985-7077-6111-4ecafbe6fbe1, uri=null]
2021-11-13 10:35:07.443 DEBUG 9204 --- [lient-AsyncIO-8] o.s.w.s.s.c.WebSocketClientSockJsSession : Transport closed with CloseStatus[code=1001, reason=] in WebSocketClientSockJsSession[id='de878120ded742a78ba92f16b12ba9e1, url=ws://localhost:57909/chess-websocket]
2021-11-13 10:35:07.443 DEBUG 9204 --- [lient-AsyncIO-8] s.w.s.h.LoggingWebSocketHandlerDecorator : WebSocketClientSockJsSession[id='de878120ded742a78ba92f16b12ba9e1, url=ws://localhost:57909/chess-websocket] closed with CloseStatus[code=1001, reason=]
2021-11-13 10:35:07.443 DEBUG 9204 --- [ionShutdownHook] s.w.s.h.LoggingWebSocketHandlerDecorator : WebSocketServerSockJsSession[id=de878120ded742a78ba92f16b12ba9e1] closed with CloseStatus[code=1001, reason=null]
2021-11-13 10:35:07.443 DEBUG 9204 --- [lient-AsyncIO-8] o.s.m.simp.stomp.DefaultStompSession     : Connection closed in session id=397d262e-13e0-8023-d8da-c88950c1d12f
2021-11-13 10:35:07.443 DEBUG 9204 --- [ionShutdownHook] o.s.w.s.m.SubProtocolWebSocketHandler    : Clearing session de878120ded742a78ba92f16b12ba9e1
2021-11-13 10:35:07.443 DEBUG 9204 --- [lient-AsyncIO-8] o.s.w.s.s.c.WebSocketClientSockJsSession : Closing session with CloseStatus[code=1000, reason=null] in WebSocketClientSockJsSession[id='de878120ded742a78ba92f16b12ba9e1, url=ws://localhost:57909/chess-websocket]
2021-11-13 10:35:07.443 DEBUG 9204 --- [lient-AsyncIO-8] o.s.w.s.s.c.WebSocketClientSockJsSession : Ignoring close (already closing or closed): current state CLOSED
2021-11-13 10:35:07.444 DEBUG 9204 --- [boundChannel-11] o.s.m.s.b.SimpleBrokerMessageHandler     : Processing DISCONNECT session=de878120ded742a78ba92f16b12ba9e1
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Bean 'subProtocolWebSocketHandler' completed its stop procedure
2021-11-13 10:35:07.445 TRACE 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Asking bean 'simpAnnotationMethodMessageHandler' of type [org.springframework.web.socket.messaging.WebSocketAnnotationMethodMessageHandler] to stop
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.m.s.ExecutorSubscribableChannel      : clientInboundChannel removed WebSocketAnnotationMethodMessageHandler[prefixes=[/app/]]
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Bean 'simpAnnotationMethodMessageHandler' completed its stop procedure
2021-11-13 10:35:07.445 TRACE 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Asking bean 'simpleBrokerMessageHandler' of type [org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler] to stop
2021-11-13 10:35:07.445  INFO 9204 --- [ionShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler     : Stopping...
2021-11-13 10:35:07.445  INFO 9204 --- [ionShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler     : BrokerAvailabilityEvent[available=false, SimpleBrokerMessageHandler [org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry@22048bd6]]
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.m.s.ExecutorSubscribableChannel      : clientInboundChannel removed SimpleBrokerMessageHandler [org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry@22048bd6]
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.m.s.ExecutorSubscribableChannel      : brokerChannel removed SimpleBrokerMessageHandler [org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry@22048bd6]
2021-11-13 10:35:07.445  INFO 9204 --- [ionShutdownHook] o.s.m.s.b.SimpleBrokerMessageHandler     : Stopped.
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Bean 'simpleBrokerMessageHandler' completed its stop procedure
2021-11-13 10:35:07.445 TRACE 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Asking bean 'userDestinationMessageHandler' of type [org.springframework.messaging.simp.user.UserDestinationMessageHandler] to stop
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.m.s.ExecutorSubscribableChannel      : clientInboundChannel removed UserDestinationMessageHandler[DefaultUserDestinationResolver[prefix=/user/]]
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.m.s.ExecutorSubscribableChannel      : brokerChannel removed UserDestinationMessageHandler[DefaultUserDestinationResolver[prefix=/user/]]
2021-11-13 10:35:07.445 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Bean 'userDestinationMessageHandler' completed its stop procedure
2021-11-13 10:35:07.445 TRACE 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Asking bean 'webServerGracefulShutdown' of type [org.springframework.boot.web.context.WebServerGracefulShutdownLifecycle] to stop
2021-11-13 10:35:07.446 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Bean 'webServerGracefulShutdown' completed its stop procedure
2021-11-13 10:35:07.447 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483646
2021-11-13 10:35:07.447 TRACE 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Asking bean 'webServerStartStop' of type [org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle] to stop
2021-11-13 10:35:07.475 DEBUG 9204 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor  : Bean 'webServerStartStop' completed its stop procedure
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释 
* 2021-11-13 10:35:07.475 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3bd3d05e: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,org.springframework.boot.test.mock.mockito.MockitoPostProcessor$SpyPostProcessor,org.springframework.boot.test.mock.mockito.MockitoPostProcessor,org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer$TestRestTemplateRegistrar,cairnServerApplication,org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory,webSocketConfig,roomController,boardService,roomService,org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration,stompWebSocketHandlerMapping,subProtocolWebSocketHandler,webSocketScopeConfigurer,webSocketMessageBrokerStats,clientInboundChannel,clientInboundChannelExecutor,clientOutboundChannel,clientOutboundChannelExecutor,brokerChannel,brokerChannelExecutor,simpAnnotationMethodMessageHandler,simpleBrokerMessageHandler,stompBrokerRelayMessageHandler,userDestinationMessageHandler,userRegistryMessageHandler,messageBrokerTaskScheduler,brokerMessagingTemplate,brokerMessageConverter,userDestinationResolver,userRegistry,org.springframework.boot.autoconfigure.AutoConfigurationPackages,org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,propertySourcesPlaceholderConfigurer,org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration$TomcatWebSocketConfiguration,websocketServletWebServerCustomizer,org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration,org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryConfiguration$EmbeddedTomcat,tomcatServletWebServerFactory,org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration,servletWebServerFactoryCustomizer,tomcatServletWebServerFactoryCustomizer,org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor,org.springframework.boot.context.internalConfigurationPropertiesBinderFactory,org.springframework.boot.context.internalConfigurationPropertiesBinder,org.springframework.boot.context.properties.BoundConfigurationProperties,org.springframework.boot.context.properties.EnableConfigurationPropertiesRegistrar.methodValidationExcludeFilter,server-org.springframework.boot.autoconfigure.web.ServerProperties,webServerFactoryCustomizerBeanPostProcessor,errorPageRegistrarBeanPostProcessor,org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration$DispatcherServletConfiguration,dispatcherServlet,spring.mvc-org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties,org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration,dispatcherServletRegistration,org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration,org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,taskExecutorBuilder,spring.task.execution-org.springframework.boot.autoconfigure.task.TaskExecutionProperties,org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration,error,beanNameViewResolver,org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration,conventionErrorViewResolver,spring.web-org.springframework.boot.autoconfigure.web.WebProperties,spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties,org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration,errorAttributes,basicErrorController,errorPageCustomizer,preserveErrorControllerTargetClassPostProcessor,org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration,requestMappingHandlerAdapter,requestMappingHandlerMapping,welcomePageHandlerMapping,localeResolver,themeResolver,flashMapManager,mvcConversionService,mvcValidator,mvcContentNegotiationManager,mvcPatternParser,mvcUrlPathHelper,mvcPathMatcher,viewControllerHandlerMapping,beanNameHandlerMapping,routerFunctionMapping,resourceHandlerMapping,mvcResourceUrlProvider,defaultServletHandlerMapping,handlerFunctionAdapter,mvcUriComponentsContributor,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,mvcViewResolver,mvcHandlerMappingIntrospector,viewNameTranslator,org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter,defaultViewResolver,viewResolver,requestContextFilter,org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration,formContentFilter,org.springframework.boot.autoconfigure.aop.AopAutoConfiguration$ClassProxyingConfiguration,forceAutoProxyCreatorToUseClassProxying,org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration,applicationAvailability,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration,standardJacksonObjectMapperBuilderCustomizer,spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration,jacksonObjectMapperBuilder,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration,parameterNamesModule,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration,jacksonObjectMapper,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,jsonComponentModule,org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration,lifecycleProcessor,spring.lifecycle-org.springframework.boot.autoconfigure.context.LifecycleProperties,org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration,stringHttpMessageConverter,org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration,mappingJackson2HttpMessageConverter,org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration,org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,messageConverters,org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties,org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration,spring.sql.init-org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties,org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer$DependsOnDatabaseInitializationPostProcessor,org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration,scheduledBeanLazyInitializationExcludeFilter,taskSchedulerBuilder,spring.task.scheduling-org.springframework.boot.autoconfigure.task.TaskSchedulingProperties,org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration,restTemplateBuilderConfigurer,restTemplateBuilder,org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration$TomcatWebServerFactoryCustomizerConfiguration,tomcatWebServerFactoryCustomizer,org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration,org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration,characterEncodingFilter,localeCharsetMappingsCustomizer,org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration,multipartConfigElement,multipartResolver,spring.servlet.multipart-org.springframework.boot.autoconfigure.web.servlet.MultipartProperties,org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration$WebSocketMessageConverterConfiguration,eagerStompWebSocketHandlerMapping,org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration,org.springframework.boot.test.web.client.TestRestTemplate,org.springframework.aop.config.internalAutoProxyCreator]; root of factory hierarchy
*/
2021-11-13 10:35:07.475 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'mvcResourceUrlProvider': [requestMappingHandlerMapping, welcomePageHandlerMapping, viewControllerHandlerMapping, beanNameHandlerMapping, routerFunctionMapping, resourceHandlerMapping]
2021-11-13 10:35:07.476 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'userRegistry': [userDestinationResolver, userRegistryMessageHandler]
2021-11-13 10:35:07.476 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'userDestinationResolver': [userDestinationMessageHandler, stompBrokerRelayMessageHandler, simpleBrokerMessageHandler]
2021-11-13 10:35:07.476 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'userDestinationMessageHandler': [stompBrokerRelayMessageHandler]
2021-11-13 10:35:07.476 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'stompBrokerRelayMessageHandler': [webSocketMessageBrokerStats]
2021-11-13 10:35:07.476 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'messageBrokerTaskScheduler': [stompWebSocketHandlerMapping]
2021-11-13 10:35:07.476 TRACE 9204 --- [ionShutdownHook] o.s.b.f.support.DisposableBeanAdapter    : Invoking destroy() on bean with name 'messageBrokerTaskScheduler'
2021-11-13 10:35:07.476 DEBUG 9204 --- [ionShutdownHook] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'messageBrokerTaskScheduler'
2021-11-13 10:35:07.476 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'brokerChannelExecutor': [brokerChannel]
2021-11-13 10:35:07.477 TRACE 9204 --- [ionShutdownHook] o.s.b.f.s.DefaultListableBeanFactory     : Retrieved dependent beans for bean 'brokerChannel': [brokerMessagingTemplate]
Complete

一个想法是,这可能是由于一个库不支持Java 17,尽管我找不到任何关于它的东西。

是什么导致了这一切?

EN

Stack Overflow用户

发布于 2021-11-13 10:52:50

我已经弄清楚是什么导致了这一切。在ObjectMapper将对象转换为JSON之前,测试将关闭服务器。

为了解决这个问题,我在测试中使用了一个BlockingQueue,并在发送消息后进行了1秒的轮询。

代码语言:javascript
运行
复制
BlockingQueue<String> blockingQueue = new ArrayBlockingQueue(1);

stompSession.subscribe("/topic/greetings", new StompFrameHandler() {

    @Override
    public Type getPayloadType(StompHeaders headers) {
        return String.class;
    }

    @Override
    public void handleFrame(StompHeaders headers, Object payload) {
        System.out.println("Received message: " + payload);

    }
});

stompSession.send("/app/welcome/test", "Mike");
blockingQueue.poll(1, SECONDS);
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69950567

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档