测试类别:-
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { WebsocketSourceConfiguration.class,
WebSocketSourceIntegrationTests.class }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
"websocket.path=/some_websocket_path", "websocket.allowedOrigins=*",
"spring.cloud.stream.default-binder=kafka" })
public class WebSocketSourceIntegrationTests {
private String port = "8080";
@Test
public void testWebSocketStreamSource() throws IOException, InterruptedException {
StandardWebSocketClient webSocketClient = new StandardWebSocketClient();
ClientWebSocketContainer clientWebSocketContainer = new ClientWebSocketContainer(webSocketClient,
"ws://localhost:" + port + "/some_websocket_path");
clientWebSocketContainer.start();
WebSocketSession session = clientWebSocketContainer.getSession(null);
session.sendMessage(new TextMessage("foo"));
System.out.println("Done****************************************************");
}
}
我spring-boot-starter-tomcat
在依赖关系层次结构中具有编译时依赖关系。
该消息表明: 您需要在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();
}
}
或还使自动配置功能能够对这些bean进行类路径扫描和自动配置。
@EnableAutoConfiguration
WebsocketSourceConfiguration
也可以在集成测试课程中完成。
@EnableAutoConfiguration
WebSocketSourceIntegrationTests
问题内容: 我已经使用Spring Boot编写了Spring Batch应用程序。当我尝试在本地系统上使用命令行和类路径运行该应用程序时,它运行良好。但是,当我尝试在linux服务器上运行它时,出现以下异常 下面是我的运行方式: 问题答案: 可能你缺少Spring Boot入门类。
我正在尝试启动一个简单的spring应用程序 我有主管道。java文件就在这里: 这是pom。xml: 最后一个错误是: 据我所知我少了一颗豆子?然而,看起来好像我有罐子春豆。
Maven build成功了,但当我尝试运行它时失败了: 我有带 一切似乎都准备就绪。发生了什么? pom.xml 更新1 使用IntelliJ构建jar工件时也是如此。 更新2 好的,我设法运行了它,但现在我有: 更新3 通过添加到应用程序使其正常工作。爪哇:
我有一个新的springboot应用程序,我试图开始。 我收到的错误是 src/main/Java/bubble shadow/root controller . Java src/test/java/test/RootControllerTest.java
我已经编写了一个使用Spring Boot的Spring批处理应用程序。当我试图在本地系统上使用命令行和类路径运行该应用程序时,它运行良好。然而,当我试图在linux服务器上运行它时,它给我以下异常 下面是我运行它的方式:
尝试设置一个简单的Web应用程序调度程序。这是我的配置: 我的课程如下所示 但是当我试图启动容器时我看到了异常 我尝试遵循Spring Boot测试:由于缺少EmbeddedServletContainerFactorybean,无法启动EmbeddedWebApplicationContext,但没有成功。 谢谢你的建议
我检查了它引用的目录,有一个catalina.sh文件,但没有。bat文件。有谁知道获取这个文件的提示或者如何让NetBeans运行。sh文件吗?
问题内容: 我收到以下异常: 应用程序入门类是这样的: 如你所见,main方法包含一个注释行。但是我无法运行ScheduledTasks应用程序,如下所示: 我使用Eclipse并将Application.java的主程序作为应用程序运行。有人可以帮我吗? 问题答案: 调度指南不是Web应用程序,因此REST指南中的pom.xml中可能包含一些发霉的东西?如果你严格按照说明进行操作,那么它应该可以