【问题标题】:Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean if i try to move to netty如果我尝试移至 netty,由于缺少 ServletWebServerFactory bean 无法启动 ServletWebServerApplicationContext
【发布时间】:2021-06-19 22:21:45
【问题描述】:

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

遇到上述异常。我正在尝试迁移到 webflux 附带的 netty 服务器。我已经删除了 spring-boot-starter-web,这样 tomcat 就不会随之而来。以下是我的主要课程:

public class Main {

    public static void main(String[] args) {
        try{
            SpringApplication.run(Main.class, args);
        }catch(Exception e){
            System.out.println("failed"+e);
        }
    }

}

【问题讨论】:

    标签: spring-boot spring-webflux


    【解决方案1】:

    @SpringBootApplication 添加到您的主类。这告诉 Spring 起点在​​哪里,没有这个 Spring 将无法引导您的应用程序。

    @SpringBootApplication
    public class Main {
    
    public static void main(String[] args) {
        try{
            SpringApplication.run(Main.class, args);
        }catch(Exception e){
            System.out.println("failed"+e);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-10-18
      • 2019-08-07
      • 2019-04-13
      • 2018-03-09
      • 1970-01-01
      • 2019-12-03
      • 2019-12-01
      • 2018-12-16
      相关资源
      最近更新 更多