繁体   English   中英

SpringBoot入门:无法启动

[英]SpringBoot getting started: Failed to start

我创建了我的第一个spring boot项目,并从springs官方网站复制了逐字示例。

但是,当我尝试开始使用mvn spring:run ,它失败,但出现以下异常:

org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

您没有说您的项目是否为Web项目。 另外,由于我看不到您的application.propertiesapplication.yaml 原因可能太多,而您的问题所提供的信息却有限,我试图猜测答案。

如果这不起作用。 使用更多信息更新您的问题。

如果您的项目不是Web应用程序项目,请尝试在application.properties上设置以下内容

spring.main.web-application-type=none

如果您有application.yaml ,请设置以下

spring:
  main:
    web-application-type: none

由于信息有限,因此很难说出您的应用程序有什么问题。 我有一个类似的问题,我相信这是由于下载的jar文件损坏造成的。 我解决了这个github问题

ServletWebServerApplicationContext due to missing ServletWebServerFactory bean可能有以下原因ServletWebServerApplicationContext due to missing ServletWebServerFactory bean

  1. pom中可能缺少Web依赖项

     <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> 
  2. 您尚未将@SpringBootApplication @SpringBootApplication为主类:

     @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } 

    }

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM