[英]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.