相关疑难解决方法(0)

Spring Boot 2中缺少TomcatEmbeddedServletContainerFactory

我有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)

java spring spring-boot

53
推荐指数
3
解决办法
3万
查看次数

Spring启动测试失败说,由于缺少ServletWebServerFactory bean,无法启动ServletWebServerApplicationContext

测试类: -

@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在依赖关系层次结构中具有编译时依赖性.

java spring spring-boot spring-cloud-stream

19
推荐指数
1
解决办法
4万
查看次数

无法在 Tomcat7 上运行 Spring Boot 2.0:“由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext。”

我需要在 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)

java spring maven tomcat7 spring-boot

1
推荐指数
1
解决办法
1067
查看次数

标签 统计

java ×3

spring ×3

spring-boot ×3

maven ×1

spring-cloud-stream ×1

tomcat7 ×1