我有Spring Boot应用程序版本1.5.x,它正在使用org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory,我正在尝试将其迁移到Spring Boot 2,但该应用程序无法编译,尽管它具有依赖性org.springframework.boot:spring-boot-starter-tomcat.编译器发出以下错误:
error: package org.springframework.boot.context.embedded.tomcat
Run Code Online (Sandbox Code Playgroud) 测试类: -
@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****************************************************");
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里看到了同样的问题,但没有任何帮助.我可以知道我错过了什么吗?
我spring-boot-starter-tomcat在依赖关系层次结构中具有编译时依赖性.
我需要在 tomcat 7 上运行我的 spring boot 2.0 应用程序
我收到这个错误
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) on project Demo: An exception occurred while running. null: InvocationTargetException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more …Run Code Online (Sandbox Code Playgroud)