您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

由于缺少ServletWebServerFactory bean,因此无法启动ServletWebServerApplicationContext

由于缺少ServletWebServerFactory bean,因此无法启动ServletWebServerApplicationContext

该消息表明: 您需要在ApplicationContext中至少配置1个ServletWebServerFactory bean ,因此,如果您已经具有spring-boot-starter-tomcat,则 。

因此,在测试中,只有2个配置类可加载applicationContext,它们是= {WebsocketSourceConfiguration.class,WebSocketSourceIntegrationTests.class},然后至少在这些类之一中,应该有一个@Bean方法返回所需实例的实例。 ServletWebServerFactory。

确保加载配置类中的所有bean

WebsocketSourceConfiguration {
  @Bean 
  ServletWebServerFactory servletWebServerFactory(){
  return new TomcatServletWebServerFactory();
  }
}

或还使自动配置功能能够对这些bean进行类路径扫描和自动配置

@EnableAutoConfiguration
WebsocketSourceConfiguration

也可以在集成测试课程中完成。

@EnableAutoConfiguration
WebSocketSourceIntegrationTests

有关更多信息,请查看 注释文档 https://docs.spring.io/spring- boot/docs/current/apI/Org/springframework/boot/test/context/SpringBootTest.html

Jave 2022/1/1 18:23:53 有347人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶