SoFunction
Updated on 2025-03-08

Solve the problem of program startup error: Unable to start web server

1. Scene

1. The project starts normally on Linux and local computers

2. If you start on another computer, it will report an error.

3. The codes are the same, there is no difference

2. Error message

: Unable to start web server; nested exception is : Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
    at (:157)
    at (:543)
    at (:142)
    at (:775)
    at (:397)
    at (:316)
    at (:1260)
    at (:1248)
    at (:32)
Caused by: : Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
    at (:206)
    at (:180)
    at (:154)
    ... 8 common frames omitted

3. Reason

The scope defined when importing spring-boot-starter-tomcat dependency results in

Original dependency import configuration

<dependency>
	<groupId></groupId>
	<artifactId>spring-boot-starter-tomcat</artifactId>
    <!--yesprovidedlead to-->
	<scope>provided</scope>
</dependency>

4. Solve

Adjusted dependency import configuration

<dependency>
	<groupId></groupId>
	<artifactId>spring-boot-starter-tomcat</artifactId>
    <!--Comment the configuration first during testing-->
	<!--<scope>provided</scope>-->
</dependency>

Note:

  • Even if the machine is provided, it can start normally
  • It won't work on another computer
  • It should be a difference in the operating environment

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.