该消息表明: 你需要在ApplicationContext中至少配置1个ServletWebServerFactory bean,因此,如果你已经具有spring-boot-starter-tomcat,则你需要自动配置该bean或手动进行配置。
因此,在测试中,只有2个配置类可以加载applicationContext,它们是= {WebsocketSourceConfiguration.class,WebSocketSourceIntegrationTests.class},然后至少在这些类之一中,应该有一个@Bean方法返回所需实例的实例。 ServletWebServerFactory。
解决方案
确保加载配置类中的所有bean
WebsocketSourceConfiguration {
@Bean
ServletWebServerFactory servletWebServerFactory(){
return new TomcatServletWebServerFactory();
}
}
@EnableAutoConfiguration
WebsocketSourceConfiguration
也可以在集成测试课程中完成。
@EnableAutoConfiguration
WebSocketSourceIntegrationTests