简体   繁体   English

Spring 启动 maven 项目由于缺少 ServletWebServerFactory bean 无法启动 ServletWebServerApplicationContext

[英]Spring Boot maven project unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

The project is working fine on the VScode, but when I try to build as .jar and run in EC2 ubuntu instance or in my local, I am facing the following error message when I try to run by this command.该项目在 VScode 上运行良好,但是当我尝试构建为.jar并在 EC2 ubuntu 实例或我的本地运行时,当我尝试通过此命令运行时,我面临以下错误消息。

java -jar project-name.jar
13:54:04.899 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
        at com.ndb.auction.AuctionApplication.main(AuctionApplication.java:21)
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:210)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160)
        ... 8 common frames omitted
@SpringBootApplication
@EnableScheduling
@EnableAutoConfiguration
public class AuctionApplication {

    public static void main(String[] args) {
        SpringApplication.run(AuctionApplication.class, args);
    }
    
    @Bean
    GraphQLScalarType uploadScalarType() {
        return ApolloScalars.Upload;
    }
}
public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(AuctionApplication.class);
    }

}

There is an issue with building jar in VScode, I tried Spring Tool Suite (spring-tool-suite-3.9.12.RELEASE-e4.15.0-win32-x86_64) to build jar file, and it is working now. There is an issue with building jar in VScode, I tried Spring Tool Suite (spring-tool-suite-3.9.12.RELEASE-e4.15.0-win32-x86_64) to build jar file, and it is working now.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jetty 9 + Spring 引导 - 由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext - Jetty 9 + Spring Boot - Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 由于缺少ServletWebServerFactory bean,无法启动ServletWebServerApplicationContext - Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean spring-boot web 应用程序启动失败:由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext - spring-boot web app fails to start : Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean Spring boot 测试失败说,由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext - Spring boot Test fails saying, Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 无法在Tomcat7上运行Spring Boot 2.0:“由于缺少ServletWebServerFactory bean,因此无法启动ServletWebServerApplicationContext。” - Cannot run Spring Boot 2.0 on Tomcat7: “Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.” 无法启动 web 服务器; 由于缺少 ServletWebServerFactory bean,嵌套异常是无法启动 ServletWebServerApplicationContext - Unable to start web server; nested exception is Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 由于缺少ServletWebServerFactory bean,即使使用@springbootapplication,我也无法启动ServletWebServerApplicationContext - I am getting Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean even with @springbootapplication org.springframework.context.ApplicationContextException 由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext - org.springframework.context.ApplicationContextException Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 由于缺少 ServletWebServerFactory,无法启动 Web 服务器 - Unable to start web server due to missing ServletWebServerFactory Spring boot -- 由于缺少 EmbeddedServletContainerFactory bean 无法启动 EmbeddedWebApplicationContext - Spring boot -- Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM