Why does Spring Boot web app close immediately after starting?

后端 未结 10 2389
南笙
南笙 2021-02-18 15:57

Using STS, if I import the \"Rest Service\" Getting Started project using the latest Spring Boot and choose \"Run As Spring Boot App\", it starts up, t

10条回答
  •  旧时难觅i
    2021-02-18 16:25

    I found the reason for this to happen. Mine was that I did not include any library which brings in the tomcat runtime with it. I included the spring-web dependency and spring-boot-starter-data-jpa(shown below) but none of these packages will bring the tomcat runtime for this app to run. So, it was auto shutdown.

    
        org.springframework.boot
        spring-boot-starter-data-jpa
    
    
        org.springframework.boot
        spring-web
    
    

    The solution was to change the spring-web to spring-boot-starter-web(shown below). This library brings in the tomcat library and my app started.

    
        org.springframework.boot
        spring-boot-starter-data-jpa
    
    
        org.springframework.boot
        spring-boot-starter-web
    
    

提交回复
热议问题